Button Variants


The primary button is used for the most important button on the page. Secondary buttons can be used for actions that are less important. Button links can be helpful for buttons that do not need a lot of attention drawn to them. Disabled buttons are used when you don't want the user to click the button. Danger buttons are used to indicate destructive actions such as deleting.

Reaction Button


The reaction variant accepts any HTML Emoji or it's hexa/decimal ref (see here) as a string within the icon prop. If nothing is passed to the icon prop, the default reaction button will be displayed as seen in the third example. The default reaction button will also be rendered if a Fontawesome icon (not an Emoji) is passed to the icon prop of a reaction variant, but the default "smiley +" icon will be replaced with the named icon.

Reaction buttons also accept two additional (optional) props: count, which accepts a number (i.e., a count of reactions) to be displayed next to the Emoji; and highlight, which is a boolean that if true, displays the 'active' state for the button. Click the first reaction button to see this in action!

Button Full Width


This button is used many times for mobile or other things like cards and sidebars.

Responsive display and full_width

full_width applies block styling that includes display: flex on the same element as the button. The display global prop also sets display (via utility classes, often with !important).

Putting both on one button means two systems control display on one node, which can cause wrong visibility (e.g. both a header and a full-width mobile button showing) or confusing cascade behavior.

Recommended: Put responsive display on a parent (e.g. Flex, Card, or a plain wrapper) and keep full_width only on the Button inside. The wrapper handles show/hide by breakpoint; the button only handles full-width layout.

<%= pb_rails("flex", props: {
  display: { xs: "flex", default: "none" },
  orientation: "column",
  width: "100%",
}) do %>
  <%= pb_rails("button", props: { full_width: true, text: "Add" }) %>
<% end %>
Button Loading

Button variants with loading
Button sizes with loading

Used when a button will take a little while to load. The spinner lets the user know that the button has worked and it is in the process of loading.

NOTE: In Rails, both the button text and loading spinner are rendered at the same time, and visibility is toggled between them. Even though the text prop is not required, providing it ensures the button maintains its correct shape during loading.

Button Block Content


Used when the user wants to display custom content within a button instead of passing in text or props to the kit itself. In this example the button is using the Pill kit and a <span> element inside the button.

Button Icon Options


Icons can also be added to a button if needed. By default, the icon will be displayed on the left of the text. To display the icon on the right, use the optional prop of iconRight in react or icon_right in rails.

Button Accessibility Options

Button with ARIA
Button Additional Options


Button Size


By default button has the md size style, even if you don't explicitly pass a size prop.

Button Form Attribute


Button Toggle Disabled State

I am an <a> Button

If needing to toggle the disabled state of the Button dynamically (for example, within a Turbo or Stimulus context), you can now do so in rails using the pb-button-managed data attribute.

1) Add the following data attribute to your button kit: data:{ pb-button-managed: true }

2) To toggle enabled/disabled state via attributes: for buttons set/remove disabled, for links set/remove aria-disabled="true". This will handle disabling the button, preventing clicks as well as all style changes so you don't have to.

Click to enable or disable the buttons above and view the code snippet below for details!

Button Toggle Disabled State Helper



The disabled state for the button can also be toggled via small helpers available through the pb-button-managed data attribute.

1) Add the following data attribute to your button kit: data:{ pb-button-managed: true }

2) Toggle state via the provided _pbButton.disable() and _pbButton.enable() helpers as shown in the code snippet below.

Click to enable or disable the buttons above to see this in action!

Icon Button Variant

Small Size (sm)
Medium Size (md)
Large Size (lg)

The icon button variant automatically renders when you provide an icon prop without a corresponding text prop. The button will only display an icon (no text) and will be wrapped with the icon button styling. This works with all button variants including "link", "primary", "secondary", etc. Simply use <%= pb_rails("button", props: { icon: "plus", variant: "secondary" }) %> to get an icon button.


Things to Avoid

Never use more than one primary button on a page at any given time.


Available Props

Props Type Values

align_content

enum | responsive
start
end
center
spaceBetween
spaceAround
spaceEvenly

align_items

enum | responsive
start
end
center

border_radius

enum
none
xs
sm
md
lg
xl
rounded

cursor

enum
auto
default
none
contextMenu
help
pointer
progress
wait
cell

dark

boolean
true
false

flex

enum | responsive
auto
initial
0
1
2
3
4
5
6
7
8
9
10
11
12
none

flex_direction

enum | responsive
row
column
rowReverse
columnReverse

flex_wrap

enum | responsive
wrap
nowrap
wrapReverse

justify_content

enum | responsive
start
end
center
spaceBetween
spaceAround
spaceEvenly

line_height

enum
loosest
looser
loose
normal
tight
tighter
tightest

margin_right

array
none
xxs
xs
sm
md
lg
xl

margin_left

array
none
xxs
xs
sm
md
lg
xl

margin_top

array
none
xxs
xs
sm
md
lg
xl

margin_bottom

array
none
xxs
xs
sm
md
lg
xl

margin_x

array
none
xxs
xs
sm
md
lg
xl

margin_y

array
none
xxs
xs
sm
md
lg
xl

margin

array
none
xxs
xs
sm
md
lg
xl

width

string

min_width

string

max_width

string

gap

string | responsive

column_gap

string | responsive

row_gap

string | responsive

number_spacing

enum
tabular

order

enum | responsive
none
first
1
2
3
4
5
6
7
8
9
10
11
12

overflow_x

enum
scroll
visible
hidden
auto

overflow_y

enum
scroll
visible
hidden
auto

overflow

enum
scroll
visible
hidden
auto

padding_right

array
none
xxs
xs
sm
md
lg
xl

padding_left

array
none
xxs
xs
sm
md
lg
xl

padding_top

array
none
xxs
xs
sm
md
lg
xl

padding_bottom

array
none
xxs
xs
sm
md
lg
xl

padding_x

array
none
xxs
xs
sm
md
lg
xl

padding_y

array
none
xxs
xs
sm
md
lg
xl

padding

array
none
xxs
xs
sm
md
lg
xl

position

enum
relative
absolute
fixed
sticky
static

shadow

enum
none
deep
deeper
deepest

text_align

enum | responsive
start
end
left
right
center
justify
justifyAll
matchParent

truncate

enum
none
1
2
3
4
5

vertical_align

enum | responsive
baseline
super
top
middle
bottom
sub
text-top
text-bottom

z_index

enum | responsive
1
2
3
4
5
6
7
8
9
10
max

top

enum | object
xxs
xs
sm
md
lg
xl
xxl

inset

boolean
true
false

right

enum | object
xxs
xs
sm
md
lg
xl
xxl

bottom

enum | object
xxs
xs
sm
md
lg
xl
xxl

left

enum | object
xxs
xs
sm
md
lg
xl
xxl

height

string

max_height

string

min_height

string

hover

object

group_hover

boolean
true
false
Props Type Values Default

count

number

disabled

boolean
true
false
false

fixed_width

boolean
true
false

form

string

full_width

boolean
true
false
false

highlight

boolean
true
false
false

icon

string

icon_right

boolean
true
false
false

link

string

loading

boolean
true
false
false

new_window

boolean
true
false
false

on_click

function

tab_index

number

size

enum
sm
md
lg

target

string

text

string

type

enum
inline
inline

html_type

enum
submit
reset
button

value

string | null

variant

enum
primary
secondary
link
danger
reaction
primary

wrapper_class

string

icon_font_family

enum
far
fas
fab
fak
far