2017-10-10 21:21:12 -04:00
---
extends: _layouts.markdown
title: "Buttons"
---
# Buttons
2017-10-17 14:54:42 -04:00
We don't ship any default button components because every app has it's own visual style and Tailwind tries to be as unopinionated as possible about how your project should look.
2017-10-10 21:21:12 -04:00
2017-10-17 14:54:42 -04:00
That said, buttons are easy to build by combining utility classes.
2017-10-10 21:21:12 -04:00
2017-10-17 14:54:42 -04:00
Here's a bunch of examples:
2017-10-10 21:21:12 -04:00
2017-10-17 14:54:42 -04:00
### Simple
2017-10-10 21:21:12 -04:00
2017-10-17 15:38:48 -04:00
@component ('_partials.code-sample', ['lang' => 'html', 'class' => 'text-center'])
2017-10-19 12:06:17 -04:00
< button class = "bg-blue hover:bg-blue-dark text-white font-bold py-2 px-4 rounded" >
2017-10-17 14:54:42 -04:00
Button
< / button >
@slot ('code')
<!-- Using utilities: -->
2017-10-19 12:06:17 -04:00
< button class = "bg-blue hover:bg-blue-dark text-white font-bold py-2 px-4 rounded" >
2017-10-17 14:54:42 -04:00
Button
< / button >
<!-- Extracting component classes: -->
< button class = "btn btn-blue" >
Button
< / button >
< style >
.btn {
2017-10-19 12:06:17 -04:00
@apply .font-bold .py-2 .px-4 .rounded;
2017-10-17 14:54:42 -04:00
}
.btn-blue {
@apply .bg-blue .text-white;
}
.btn-blue:hover {
@apply .bg-blue-dark;
}
< / style >
@endslot
@endcomponent
---
### Pill
2017-10-17 15:38:48 -04:00
@component ('_partials.code-sample', ['lang' => 'html', 'class' => 'text-center'])
2017-10-19 12:06:17 -04:00
< button class = "bg-blue hover:bg-blue-dark text-white font-bold py-2 px-4 rounded-pill" >
2017-10-17 14:54:42 -04:00
Button
< / button >
@endcomponent
---
### Outline
2017-10-17 15:38:48 -04:00
@component ('_partials.code-sample', ['lang' => 'html', 'class' => 'text-center'])
2017-10-19 12:06:17 -04:00
< button class = "bg-transparent hover:bg-blue text-blue-dark font-semibold hover:text-white py-2 px-4 border border-blue hover:border-transparent rounded" >
2017-10-17 14:54:42 -04:00
Button
< / button >
@endcomponent
2017-10-10 21:21:12 -04:00
2017-10-17 14:54:42 -04:00
---
### Bordered
2017-10-17 15:38:48 -04:00
@component ('_partials.code-sample', ['lang' => 'html', 'class' => 'text-center'])
2017-10-19 12:06:17 -04:00
< button class = "bg-blue hover:bg-blue-dark text-white font-bold py-2 px-4 border border-blue-darker rounded" >
2017-10-17 14:54:42 -04:00
Button
< / button >
@endcomponent
---
### Disabled
2017-10-10 21:21:12 -04:00
2017-10-17 15:38:48 -04:00
@component ('_partials.code-sample', ['lang' => 'html', 'class' => 'text-center'])
2017-10-19 12:06:17 -04:00
< button class = "bg-blue text-white font-bold py-2 px-4 rounded opacity-50 cursor-not-allowed" >
2017-10-17 14:54:42 -04:00
Button
< / button >
@endcomponent
---
### 3D
2017-10-17 15:38:48 -04:00
@component ('_partials.code-sample', ['lang' => 'html', 'class' => 'text-center'])
2017-10-26 16:00:05 -04:00
< button class = "bg-blue hover:bg-blue-light text-white font-bold py-2 px-4 border-b-4 border-blue-dark hover:border-blue rounded" >
2017-10-17 14:54:42 -04:00
Button
< / button >
@endcomponent
---
### Elevated
2017-10-17 15:38:48 -04:00
@component ('_partials.code-sample', ['lang' => 'html', 'class' => 'text-center'])
2017-10-19 12:06:17 -04:00
< button class = "bg-white hover:bg-smoke-lighter text-slate-dark font-semibold py-2 px-4 border border-slate-lighter rounded shadow" >
2017-10-17 14:54:42 -04:00
Button
< / button >
@endcomponent
---
### Button Groups
2017-10-17 15:38:48 -04:00
@component ('_partials.code-sample', ['lang' => 'html', 'class' => 'text-center'])
2017-10-17 14:54:42 -04:00
< div class = "inline-flex" >
2017-10-19 12:06:17 -04:00
< button class = "bg-smoke hover:bg-smoke-dark text-slate-dark font-bold py-2 px-4 rounded-l" >
2017-10-17 14:54:42 -04:00
Prev
2017-10-10 21:21:12 -04:00
< / button >
2017-10-19 12:06:17 -04:00
< button class = "bg-smoke hover:bg-smoke-dark text-slate-dark font-bold py-2 px-4 rounded-r" >
2017-10-17 14:54:42 -04:00
Next
2017-10-10 21:21:12 -04:00
< / button >
< / div >
2017-10-17 14:54:42 -04:00
@endcomponent
---
### w/Icon
2017-10-17 15:38:48 -04:00
@component ('_partials.code-sample', ['lang' => 'html', 'class' => 'text-center'])
2017-10-19 12:06:17 -04:00
< button class = "bg-smoke hover:bg-smoke-dark text-slate-dark font-bold py-2 px-4 rounded inline-flex items-center" >
2017-10-17 14:54:42 -04:00
< svg class = "h-4 mr-2" xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 20 20" > < path d = "M13 8V2H7v6H2l8 8 8-8h-5zM0 18h20v2H0v-2z" / > < / svg >
< span > Download< / span >
< / button >
@endcomponent