RebassDemo
GitHubnpm

Getting Started

Rebass is a React UI component library that uses inline styles to avoid CSS dependencies and prevent leaky global styles from affecting an application. Rebass components inherit styles where appropriate and can be customized using React Context. Rebass components are built as stateless functional components and modeled as presentational components. With unit tests for each component, Rebass is great for prototyping and ready for production.

View the demo or read the component documentation below to get started.

npm i rebass

Arrow

Arrow for use in dropdowns and other UI elements

Example
<Button rounded={true}>
  Arrow
  <Arrow direction="down" />
</Button>

Variations

PropTypeDescription
direction oneOf(['up', 'down'])Direction of arrow

Avatar

A circular image for displaying user avatars

Example
<Avatar
  size={48}
  src="http://lorempixel.com/64/64/cats"
/>
PropTypeDescription
size numberWidth and height of image in pixels

Badge

Component for displaying flash and error messages

Example

Rebass
0.2.0

Pill
Pill

Circular Things
4

<Flex align="center">
  <Heading level={4}>
    Rebass 
    <Space x={1} />
    <Badge type="info">
      0.2.0
    </Badge>
  </Heading>
  <Space x={2} />
  <Heading level={4}>
    Pill 
    <Space x={1} />
    <Badge
      pill={true}
      type="info"
    >
      Pill
    </Badge>
  </Heading>
  <Space x={2} />
  <Heading level={4}>
    Circular Things 
    <Space x={1} />
    <Badge
      circle={true}
      type="error"
    >
      4
    </Badge>
  </Heading>
</Flex>

Variations

Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
Badge
PropTypeDescription
type oneOf(['default', 'info', 'success', 'warning', 'error'])Sets color based on type of badge
pill boolSets pill style border radii
circle boolSets width and border radius for circular badges

Block

Generic box with visual styling

Example

Block

Generic box for containing things

<Block
  borderLeft={true}
  color="blue"
>
  <Media img="http://placehold.it/128/08e/fff">
    <Heading
      level={2}
      size={0}
    >
      Block
    </Heading>
    <Text>
      Generic box for containing things
    </Text>
  </Media>
</Block>
PropTypeDescription
color stringText color - can either be a key from the theme colors object or any color value
backgroundColor stringBackground color - can either be a key from the theme colors object or any color value
borderColor stringBorder color - can either be a key from the theme colors object or any color value
border boolAdds a border
borderTop boolAdds a border to the top side
borderRight boolAdds a border to the right side
borderBottom boolAdds a border to the bottom side
borderLeft boolAdds a border to the left side
m oneOf([0, 1, 2, 3, 4])Applies margin with the margin utility based on the theme spacing scale
mt oneOf([0, 1, 2, 3, 4])Applies margin top based on the theme spacing scale
mr oneOf([0, 1, 2, 3, 4])Applies margin right based on the theme spacing scale
mb oneOf([0, 1, 2, 3, 4])Applies margin bottom based on the theme spacing scale
ml oneOf([0, 1, 2, 3, 4])Applies margin left based on the theme spacing scale
mx oneOf([0, 1, 2, 3, 4])Applies margin left and right based on the theme spacing scale
my oneOf([0, 1, 2, 3, 4])Applies margin top and bottom based on the theme spacing scale
p oneOf([0, 1, 2, 3, 4])Applies padding with the padding utility based on the theme spacing scale
pt oneOf([0, 1, 2, 3, 4])Applies padding top based on the theme spacing scale
pr oneOf([0, 1, 2, 3, 4])Applies padding right based on the theme spacing scale
pb oneOf([0, 1, 2, 3, 4])Applies padding bottom based on the theme spacing scale
pl oneOf([0, 1, 2, 3, 4])Applies padding left based on the theme spacing scale
px oneOf([0, 1, 2, 3, 4])Applies padding left and right based on the theme spacing scale
py oneOf([0, 1, 2, 3, 4])Applies padding top and bottom based on the theme spacing scale
rounded oneOfType([bool, oneOf(['top', 'right', 'bottom', 'left'])])Controls border radius

Button

A general purpose button element with customizable colors

Example
<div>
  <Button rounded={true}>
    Button
  </Button>
</div>

Variations

PropTypeDescription
href stringPass an href prop to make the Button an <a> tag instead of a <button>
color stringButton color - can either be a key from the theme colors object or any color value
backgroundColor stringBackground color - can either be a key from the theme colors object or any color value
rounded oneOfType([bool, oneOf(['top', 'right', 'bottom', 'left'])])Controls the border radius for creating button groups
pill boolCreates a pill style button
big boolCreates a larger button

ButtonCircle

A circular button suited for use with icons

Example
<Flex
  align="center"
  justify="space-between"
  wrap={true}
>
  <ButtonCircle title="Like">
    <Icon
      fill="currentColor"
      height="1em"
      name="heart"
      width="1em"
    />
  </ButtonCircle>
  <ButtonCircle title="Comment">
    <Icon
      fill="currentColor"
      height="1em"
      name="chat"
      width="1em"
    />
  </ButtonCircle>
  <ButtonCircle title="Repost">
    <Icon
      fill="currentColor"
      height="1em"
      name="repost"
      width="1em"
    />
  </ButtonCircle>
  <ButtonCircle title="Bookmark">
    <Icon
      fill="currentColor"
      height="1em"
      name="bookmark"
      width="1em"
    />
  </ButtonCircle>
  <ButtonCircle title="Tag">
    <Icon
      fill="currentColor"
      height="1em"
      name="tag"
      width="1em"
    />
  </ButtonCircle>
</Flex>
PropTypeDescription
href stringPass an href prop to make the ButtonCircle an <a> tag instead of a <button>
color stringText color - can either be a key from the theme colors object or any color value
backgroundColor stringBackground color - can either be a key from the theme colors object or any color value
size numberSets width and height of button

ButtonOutline

A general purpose outline style button element with customizable colors

Example
<div>
  <ButtonOutline rounded="left">
    Button
  </ButtonOutline>
  <ButtonOutline
    rounded={false}
    style={{marginLeft: -1}}
  >
    Group
  </ButtonOutline>
  <Button
    rounded="right"
    style={{marginLeft: -1}}
  >
    Button
  </Button>
</div>

Variations

PropTypeDescription
href stringPass an href prop to make the ButtonOutline an <a> tag instead of a <button>
color stringText color
rounded oneOfType([bool, oneOf(['top', 'right', 'bottom', 'left'])])Controls the border radius for creating button groups
pill boolCreates a pill style button
big boolCreates a larger button

Card

Styled box with border

Example

Card

Cats like cards too

<Card width={256}>
  <CardImage src="http://placehold.it/320/08e/fff" />
  <Heading
    level={2}
    size={3}
  >
    Card
  </Heading>
  <Text>
    Cats like cards too
  </Text>
</Card>
PropTypeDescription
width oneOfType([number, string])Width of card

CardImage

Image for use within the Card component

Example
<div style={{maxWidth: 192}}>
  <CardImage src="http://placehold.it/320/08e/fff" />
</div>
PropTypeDescription
src *stringImage source

Checkbox

Checkbox input with label

Example
<Checkbox
  label="Checkbox"
  name="checkbox_example"
/>
PropTypeDescription
label *stringLabel for form element
name *stringName attribute for form element

Close

A button with an × for close and dismiss actions

Example
<Close />

Container

Div with max-width and margin auto for centering content

Example
Container
<Container>
  Container
</Container>

Divider

Styled hr element

Example


<div>
  <Divider />
  <Divider
    ml={0}
    width={128}
  />
</div>
PropTypeDescription
width numberSets a fixed width for stylistic options

Donut

A single-value donut chart with percentage

Example
56%
9/16
63%
13%
<Flex
  align="center"
  justify="space-between"
  wrap={true}
>
  <Donut
    size={256}
    strokeWidth={32}
    value={0.5625}
  />
  <Donut
    size={128}
    strokeWidth={8}
    value={0.5625}
  >
    9/16
  </Donut>
  <Donut
    size={128}
    strokeWidth={8}
    value={0.625}
  />
  <Donut
    size={128}
    strokeWidth={8}
    value={0.125}
  />
</Flex>
PropTypeDescription
value numberValue from 0 to 1
size numberSets width and height
strokeWidth numberSets width of stroke

DotIndicator

Dot indicator buttons for use in carousels

Example
<div>
  <DotIndicator
    active={0}
    length={3}
    onClick={function noRefCheck() {}}
  />
</div>
PropTypeDescription
length numberNumber of dot buttons to show
active numberIndex of the currently active dot
onClick funcClick event callback - returns index of clicked button

Drawer

An off-canvas drawer component

Example
See Demo Page
<a href="demo">
  See Demo Page
</a>
PropTypeDescription
size numberWidth or height of drawer, depending on placement
open boolShows and hides the drawer
position oneOf(['top', 'right', 'bottom', 'left'])Position relative to the viewport
onDismiss funcClick event callback for the background overlay

Embed

Responsive media embed wrapper

Example
<Embed ratio={0.5625}>
  <iframe
    allowFullScreen={true}
    src="https://www.youtube.com/embed/KO_3Qgib6RQ"
  />
</Embed>
PropTypeDescription
ratio numberAspect ratio for the embed. Divide height over width to calculate. E.g. ratio={9/16}

Heading

Heading element with no margin and size based on fontSizes scale

Example

Variations

Heading

Heading

Heading

Heading

Heading
Heading
PropTypeDescription
level oneOf([1, 2, 3, 4, 5, 6])Heading level, e.g. level={1} for <h1>
size oneOf([0, 1, 2, 3, 4, 5, 6])Visual size of heading

InlineForm

Inline grouped form for search or other simple forms

Example
<InlineForm
  buttonLabel="Go"
  label="InlineForm"
  name="inline_form"
  onChange={function noRefCheck() {}}
  onClick={function noRefCheck() {}}
/>
PropTypeDescription
label *stringInput label
name *stringInput name
value oneOfType([number, string])Input value
placeholder stringInput placeholder
onChange funconChange handler for input
buttonLabel stringText for button
onClick funconClick handler for button

Input

Input element with label with support for aria-invalid, disabled, and readOnly HTML attributes

Example
<Input
  label="Input"
  name="input_example"
  placeholder="Placeholder"
  rounded={true}
  type="text"
/>

Variations

PropTypeDescription
label *stringLabel for form element
name *stringName attribute for form element
type stringForm element type
message stringAdds a helper or error message below the input
hideLabel boolHides the form element label
rounded oneOfType([bool, oneOf(['top', 'right', 'bottom', 'left'])])Controls the border radius for creating grouped elements

InputRange

Input type range with label

Example

Variations

PropTypeDescription
label *stringLabel for form element
name *stringName attribute for form element
hideLabel boolHides the form element label

Label

Label element for form controls

Example
<Label>
  Label for form elements
</Label>
PropTypeDescription
hide boolAccessibly hide label for use in high density UI. This can still cause accessibility issues. Use this with caution.

LinkBlock

Unstyled display block link

Example

LinkBlock

<LinkBlock
  Component="a"
  href="#LinkBlock"
>
  <Media
    align="center"
    img="http://placehold.it/96/08e/fff"
  >
    <Heading level={3}>
      LinkBlock
    </Heading>
  </Media>
</LinkBlock>
PropTypeDescription
Component nodeRoot component - useful for use with react-router's Link component

Media

Media object with vertical alignment using flexbox

Example

Media Object

With alignment options

<Media
  align="center"
  img="http://placehold.it/128/08e/fff"
>
  <Heading level={3}>
    Media Object
  </Heading>
  <Text>
    With alignment options
  </Text>
</Media>

Variations

Media
Media
Media
Media
Media
Media
PropTypeDescription
img stringImage source
right boolDisplays image to the right
align oneOf(['top', 'center', 'bottom'])Vertical alignment

Message

Component for displaying flash and error messages

Example
Hello Message!
<Message type="success">
  Hello Message!
  <Space
    auto={true}
    x={1}
  />
  <Close />
</Message>

Variations

Message
Message
Message
Message
Message
PropTypeDescription
type oneOf(['default', 'info', 'success', 'warning', 'error'])Sets color based on type of message

Overlay

Fixed positioned overlay for use with modal dialogs

Example
See demo
<a href="demo">
  See demo
</a>
PropTypeDescription
open boolShows and hides overlay
dark boolSets dark transparent overlay style
box boolSets padding and background white for the content container
fullWidth boolSets content container full width
onDismiss funcClick event callback for the Overlay background

Panel

Panel for containing small pieces of information

Example
Panel

Panels are great for visually separating UI, content, or data from the rest of the page.

The footer is a good place for less important information
<Panel type="info">
  <PanelHeader type="default">
    Panel
  </PanelHeader>
  <Text>
    Panels are great for visually separating UI, content, or data from the rest of the page.
  </Text>
  <PanelFooter type="default">
    The footer is a good place for less important information
  </PanelFooter>
</Panel>

Variations

Panel
Panel
Panel
Panel
Panel
PropTypeDescription
type oneOf(['default', 'info', 'success', 'warning', 'error'])Sets border color based on type of panel

PanelFooter

Footer for Panel component with vertical centering using flexbox

Example

Variations

PanelFooter
PanelFooter
PanelFooter
PanelFooter
PanelFooter
PropTypeDescription
type oneOf(['default', 'info', 'success', 'warning', 'error'])Sets background color based on the type of panel

PanelHeader

Header for Panel component with vertical centering using flexbox

Example

Variations

PanelHeader
PanelHeader
PanelHeader
PanelHeader
PanelHeader
PropTypeDescription
type oneOf(['default', 'info', 'success', 'warning', 'error'])Sets background color based on the type of panel

Pre

Pre element for displaying code examples

Example
const pre = { preformatted: 'text' }
<Pre>
  const pre = { preformatted: 'text' }
</Pre>

Progress

Progress element

Example
0.25
<Progress value={0.25} />
PropTypeDescription
value numberValue for progress bar

Radio

Radio input with label

Example
<Radio
  label="Radio"
  name="radio_example"
/>
PropTypeDescription
label *stringLabel for form element
name *stringName attribute for form element

Rating

Star rating component with clickable buttons

Example
<Rating value={3.5} />
PropTypeDescription
value numberNumber of star rating from 1 to 5
onClick funcClick handler - returns index of star clicked

Section

Section element with vertical padding

Example
Section
<Section>
  Section
</Section>

SectionHeader

Header for section elements

Example

Section Header

With linked header

Section
<Section>
  <SectionHeader
    description="With linked header"
    heading="Section Header"
  />
  Section
</Section>
PropTypeDescription
heading stringSection heading
href stringLink to section, used in HeadingLink
description stringDescription of section

Select

Select form control with label

Example
<Select
  label="Select"
  name="select_example"
  options={[{label: 'Two', value: 2}, {label: 'Four', value: 4}, {label: 'Eight', value: 8}, {label: 'Sixteen', value: 16}, {label: 'Thirty-Two', value: 32}, {label: 'Sixty-Four', value: 64}]}
/>

Variations

PropTypeDescription
label *stringLabel for form element
name *stringName attribute for form element
options *arrayOptions for select
message stringAdds a helper or error message below the select
hideLabel boolHides the form element label

SequenceMap

Sequence map pattern for use in multi-step forms

Example
<SequenceMap
  active={1}
  steps={[{children: 'Sign In', href: '#!'}, {children: 'Shipping Address', href: '#!'}, {children: 'Payment Method', href: '#!'}, {children: 'Place Order', href: '#!'}]}
/>
PropTypeDescription
steps arrayArray of links for each step in the sequence
active numberIndex of current step

Space

Inline-block element for adding space between elements

Example
<div>
  <Button rounded={true}>
    Button
  </Button>
  <Space x={1} />
  <Button rounded={true}>
    With
  </Button>
  <Space x={4} />
  <Button rounded={true}>
    Space
  </Button>
</div>
PropTypeDescription
x oneOf([1, 2, 3, 4])Width of space based on the spacing scale
auto boolSets flex: 1 1 auto

Stat

Styled number display for statistics

Example
512GB
Memory
32
PetaFLOPS
512Mbps
Upload
1,024Mbps
Download
<Flex
  justify="space-between"
  wrap={true}
>
  <Stat
    label="Memory"
    unit="GB"
    value="512"
  />
  <Stat
    label="PetaFLOPS"
    value="32"
  />
  <Stat
    label="Upload"
    unit="Mbps"
    value="512"
  />
  <Stat
    label="Download"
    unit="Mbps"
    value="1,024"
  />
</Flex>
PropTypeDescription
value oneOfType([number, string])Value for stat shown in large font size
unit stringOptional unit for displaying next to value
label stringLabel for stat
topLabel boolDisplays label above value

Text

Component for displaying text in UI

Example

Variations

Text

Text

PropTypeDescription
small boolSets a smaller font size

Textarea

Textarea form element with label

Example

Variations

PropTypeDescription
label *stringLabel for form element
name *stringName attribute for form element
message stringAdds a helper or error message below the textarea
hideLabel boolHides the form element label

Toolbar

Toolbar component that vertically centers children with display flex

Example
<Toolbar>
  <NavItem Component="a">
    Toolbar
  </NavItem>
  <NavItem Component="a">
    NavItem
  </NavItem>
  <Space
    auto={true}
    x={1}
  />
  <NavItem Component="a">
    NavItem
  </NavItem>
</Toolbar>

Tooltip

Styled tooltip that shows on hover

Example

Tooltip

<Tooltip title="Hello!">
  <Heading level={3}>
    Tooltip
  </Heading>
</Tooltip>
PropTypeDescription
title stringText to display in tooltip

Get Started

npm i rebass
GitHub

Documentation generated with react-docgen and react-component-permutations.