Fylgja Input Group
The Fylgja Input Group component allows you to group inputs and buttons together to create more intuitive form controls.
This component is ideal for building various UI elements such as search bars, button groups, or rating systems using radio buttons.
Installation
You can install Fylgja Input Group via npm or other Node-based package managers like pnpm or bun:
npm install @fylgja/input-group
Alternatively, you can use it directly via a CDN:
<link href="https://cdn.jsdelivr.net/npm/@fylgja/input-group/index.min.css" rel="stylesheet">
Usage
Once installed, you can import the full package with:
@import "@fylgja/input-group";
Alternatively, if you only need specific parts, you can import them individually:
Import Path | Description |
---|---|
@fylgja/input-group/base | Contains to core of the Input Group |
@fylgja/input-group/merge | Contains the --merge modifier class |
@fylgja/input-group/steps | Contains the --steps modifier class |
Modifiers
--merge
The --merge
modifier merges all borders between elements in an input group, making them appear as a unified component.
--steps
The --steps
modifier adds stepping functionality, mainly used with radio buttons or checkbox groups to create a range-like input.
Examples
These examples demonstrate how you can use the Input Group component with various form controls and modifiers.
The flexibility of this component allows you to customize form elements easily.
Search box
Create a simple search bar by combining an input field with a button:
<form action="./search/">
<label for="ui-search">Search</label>
<div class="input-group">
<input id="ui-search" name="ui-search">
<button>Search</button>
</div>
</form>
Button Group
Create a group of buttons with the --merge
modifier for a seamless design:
<div class="input-group --merge">
<button>Delete</button>
<button>Update</button>
<button>Publish</button>
</div>
You can also use checkboxes to create a toolbar. The btn class hides the input and makes the label the interactive element:
<div class="input-group --merge">
<label class="btn">
<input type="checkbox">
Mute
</label>
<label class="btn">
<input type="checkbox">
Pause
</label>
</div>
Start Rating
Use the --steps
modifier to create a rating system with radio buttons,
giving it the appearance of a step-by-step input:
<fieldset>
<legend>Your Rating</legend>
<div class="input-group --steps">
<label>
<svg ...><use href="#star" /></svg>
<input type="radio" name="demo-star-rating">
</label>
...
</div>
</fieldset>