Skip to content

Commit c28650c

Browse files
committed
a11y: improving the search input field
Signed-off-by: Christine Belzie <shecoder30@gmail.com>
1 parent c897d1b commit c28650c

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

‎src/Search.css‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.search-form {
2+
display: flex;
3+
justify-content: center;
4+
margin: 1rem 0;
5+
}
6+
7+
.search-container {
8+
width: 100%;
9+
max-width: 400px;
10+
}
11+
12+
.search-label {
13+
display: block;
14+
font-size: 1rem;
15+
color: #333;
16+
}
17+
18+
.search-input {
19+
width: 100%;
20+
padding: 0.5rem;
21+
font-size: 1rem;
22+
border: 1px solid #ccc;
23+
border-radius: 4px;
24+
}
25+
26+
.search-input:focus {
27+
border-color: #007bff;
28+
outline: none;
29+
box-shadow: 0 0 3px rgba(0, 123, 255, 0.5);
30+
}

‎src/Search.jsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ const Search = () => {
2323
</h1>
2424

2525
{!showPopularNews &&
26-
<form>
27-
<div>
26+
<form className="search-form">
27+
<div className="search-container">
28+
<label htmlFor="search-input" className="search-label">
29+
Search for articles:
30+
</label>
2831
<input type="text" placeholder="search here"
2932
value={query}
3033
onChange={(e) => searchFn(e.target.value)}

0 commit comments

Comments
 (0)