1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-09-08 21:30:50 +02:00

feat: Search box

This commit is contained in:
Phuoc Nguyen
2022-09-21 10:10:34 +07:00
parent 24b5221aea
commit 0e2ceeea1b
9 changed files with 69 additions and 218 deletions

View File

@@ -0,0 +1,4 @@
<div class="search-box">
<input type="text" class="search-box__input" />
{% circle "md" %}
</div>

View File

@@ -94,6 +94,7 @@ eleventyExcludeFromCollections: true
{% pattern "Input addon" %}{% include "patterns/input-addon.njk" %}{% endpattern %}
{% pattern "Radio switch" %}{% include "patterns/radio-switch.njk" %}{% endpattern %}
{% pattern "Rating" %}{% include "patterns/rating.njk" %}{% endpattern %}
{% pattern "Search box" %}{% include "patterns/search-box.njk" %}{% endpattern %}
</div>
</div>

40
contents/search-box.md Normal file
View File

@@ -0,0 +1,40 @@
---
layout: layouts/post.njk
title: Search box
description: Create a search box with CSS flexbox
keywords: css flexbox, css search box
---
## HTML
```html
<div class="search-box">
<!-- Text input -->
<input type="text" class="search-box__input" />
<!-- Search icon sticks to the left or right -->
...
</div>
```
## CSS
```css
.search-box {
display: flex;
/* If you want to place the icon before the text input */
flex-direction: row-reverse;
/* Border */
border: 1px solid #d1d5db;
}
.search-box__input {
border-color: transparent;
/* Take available width */
flex: 1;
}
```
{% demo %}{% include "patterns/search-box.njk" %}{% enddemo %}