Buttons are used to trigger actions in forms, modals, and more.
To render a button, apply the class a-btn
to a <button>
element.
Although buttons were designed for the <button>
element, Chi
also supports button classes on <a>
and <input>
elements.
<!-- default -->
<button class="a-btn">Button</button>
<!-- also supported -->
<a class="a-btn" role="button">Link</a>
<input class="a-btn" type="button" value="Input">
<input class="a-btn" type="submit" value="Submit">
<input class="a-btn" type="reset" value="Reset">
Chi includes a wide variety of predefined button styles. For most cases,
the base and -primary
buttons will be sufficient. For special cases,
such as styling a destructive action button, a -danger
button may be used.
<!-- default buttons -->
<button class="a-btn">Base</button>
<button class="a-btn -primary">Primary</button>
<!-- special case buttons -->
<button class="a-btn -secondary">Secondary</button>
<button class="a-btn -danger">Danger</button>
<button class="a-btn -dark">Dark</button>
To remove a buttons solid background and keep its colored border, apply the class
-outline
.
<button class="a-btn -outline">Base</button>
<button class="a-btn -primary -outline">Primary</button>
<button class="a-btn -secondary -outline">Secondary</button>
<button class="a-btn -danger -outline">Danger</button>
<button class="a-btn -dark -outline">Dark</button>
To render a button with a transparent background and border, apply the class
-flat
.
<button class="a-btn -flat">Base</button>
<button class="a-btn -primary -flat">Primary</button>
<button class="a-btn -secondary -flat">Secondary</button>
<button class="a-btn -danger -flat">Danger</button>
<button class="a-btn -dark -flat">Dark</button>
Use the -pill
modifier class to render buttons with a more pronounced border-radius.
<!-- default buttons -->
<button class="a-btn -pill">Base</button>
<button class="a-btn -primary -pill">Primary</button>
<!-- special case buttons -->
<button class="a-btn -secondary -pill">Secondary</button>
<button class="a-btn -danger -pill">Danger</button>
<button class="a-btn -dark -pill">Dark</button>
Buttons can be expanded to fill the parent space by applying the class -fluid
.
<!-- default buttons -->
<button class="a-btn -fluid">Base</button>
<button class="a-btn -primary -fluid">Primary</button>
<!-- special case buttons -->
<button class="a-btn -secondary -fluid">Secondary</button>
<button class="a-btn -danger -fluid">Danger</button>
<button class="a-btn -dark -fluid">Dark</button>
<button class="a-btn -pill -outline">Base</button>
<button class="a-btn -primary -pill -outline">Primary</button>
<button class="a-btn -secondary -pill -outline">Secondary</button>
<button class="a-btn -danger -pill -outline">Danger</button>
<button class="a-btn -dark -pill -outline">Dark</button>
For interfaces with limited space, an -icon
button can
be used for common actions such as editing, deleting, closing, etc.
<!-- base -->
<button class="a-btn -icon">
<div class="a-btn__content">
<div class="a-icon">
<svg>
<use xlink:href="#icon-atom"></use>
</svg>
</div>
</div>
</button>
<!-- flat -->
<button class="a-btn -icon -flat">
<div class="a-btn__content">
<div class="a-icon">
<svg>
<use xlink:href="#icon-atom"></use>
</svg>
</div>
</div>
</button>
<!-- left aligned -->
<button class="a-btn">
<div class="a-btn__content">
<div class="a-icon">
<svg>
<use xlink:href="#icon-atom"></use>
</svg>
</div>
<span>Button</span>
</div>
</button>
<!-- right aligned -->
<button class="a-btn">
<div class="a-btn__content">
<span>Button</span>
<div class="a-icon">
<svg>
<use xlink:href="#icon-atom"></use>
</svg>
</div>
</div>
</button>
<!-- both sides -->
<button class="a-btn">
<div class="a-btn__content">
<div class="a-icon">
<svg>
<use xlink:href="#icon-atom"></use>
</svg>
</div>
<span>Button</span>
<div class="a-icon">
<svg>
<use xlink:href="#icon-atom"></use>
</svg>
</div>
</div>
</button>
<button class="a-btn -float">
<div class="a-btn__content">
<div class="a-icon">
<svg>
<use xlink:href="#icon-atom"></use>
</svg>
</div>
</div>
</button>
<button class="a-btn -primary -float">
<div class="a-btn__content">
<div class="a-icon">
<svg>
<use xlink:href="#icon-atom"></use>
</svg>
</div>
</div>
</button>
<button class="a-btn -secondary -float">
<div class="a-btn__content">
<div class="a-icon">
<svg>
<use xlink:href="#icon-atom"></use>
</svg>
</div>
</div>
</button>
<button class="a-btn -float -danger">
<div class="a-btn__content">
<div class="a-icon">
<svg>
<use xlink:href="#icon-atom"></use>
</svg>
</div>
</div>
</button>
<button class="a-btn -float -dark">
<div class="a-btn__content">
<div class="a-icon">
<svg>
<use xlink:href="#icon-atom"></use>
</svg>
</div>
</div>
</button>
<button class="a-btn -icon -close">
<div class="a-btn__content">
<i class="a-icon icon-x"></i>
</div>
</button>
<button class="a-btn -icon -close">
<div class="a-btn__content">
<div class="a-icon">
<svg>
<use xlink:href="#icon-x"></use>
</svg>
</div>
</div>
</button>
Buttons supports a full spectrum of sizes: -sm
, -md
,
-lg
, -xl
.
The default size is -md
.
-sm
-md
-lg
-xl
<button class="a-btn -sm">Button -sm</button>
<button class="a-btn -sm -icon">
<div class="a-btn__content">
<div class="a-icon">
<svg>
<use xlink:href="#icon-atom"></use>
</svg>
</div>
</div>
</button>
<button class="a-btn -md">Button -md</button>
<button class="a-btn -md -icon">
<div class="a-btn__content">
<div class="a-icon">
<svg>
<use xlink:href="#icon-atom"></use>
</svg>
</div>
</div>
</button>
<button class="a-btn -lg">Button -lg</button>
<button class="a-btn -lg -icon">
<div class="a-btn__content">
<div class="a-icon">
<svg>
<use xlink:href="#icon-atom"></use>
</svg>
</div>
</div>
</button>
<button class="a-btn -xl">Button -xl</button>
<button class="a-btn -xl -icon">
<div class="a-btn__content">
<div class="a-icon">
<svg>
<use xlink:href="#icon-atom"></use>
</svg>
</div>
</div>
</button>