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
<Button rounded={true}> Arrow <Arrow direction="down" /> </Button>
Variations
Prop | Type | Description |
---|---|---|
direction | oneOf(['up', 'down']) | Direction of arrow |
Avatar
A circular image for displaying user avatars
<Avatar size={48} src="http://lorempixel.com/64/64/cats" />
Prop | Type | Description |
---|---|---|
size | number | Width and height of image in pixels |
Badge
Component for displaying flash and error messages
Rebass
Pill
Circular Things
<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
Prop | Type | Description |
---|---|---|
type | oneOf(['default', 'info', 'success', 'warning', 'error']) | Sets color based on type of badge |
pill | bool | Sets pill style border radii |
circle | bool | Sets width and border radius for circular badges |
Banner
Full-height banner with styling for background images
Rebass
<Banner align="center" backgroundImage="https://d262ilb51hltx0.cloudfront.net/max/2000/1*DZwdGMaeu-rvTroJYui6Uw.jpeg" > <Heading level={2} size={0} > Rebass </Heading> </Banner>
Prop | Type | Description |
---|---|---|
align | oneOf(['left', 'center', 'right']) | Horizontal alignment |
backgroundImage | string | Background image source |
Block
Generic box with visual styling
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>
Prop | Type | Description |
---|---|---|
color | string | Text color - can either be a key from the theme colors object or any color value |
backgroundColor | string | Background color - can either be a key from the theme colors object or any color value |
borderColor | string | Border color - can either be a key from the theme colors object or any color value |
border | bool | Adds a border |
borderTop | bool | Adds a border to the top side |
borderRight | bool | Adds a border to the right side |
borderBottom | bool | Adds a border to the bottom side |
borderLeft | bool | Adds 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 |
Breadcrumbs
Breadcrumb navigation links
<Breadcrumbs links={[{children: 'Jxnblk', href: '#!'}, {children: 'Rebass', href: '#!'}, {children: 'Breadcrumbs', href: '#!'}]} />
Prop | Type | Description |
---|---|---|
links * | array | Array of link props |
Button
A general purpose button element with customizable colors
<div> <Button rounded={true}> Button </Button> </div>
Variations
Prop | Type | Description |
---|---|---|
href | string | Pass an href prop to make the Button an <a> tag instead of a <button> |
color | string | Button color - can either be a key from the theme colors object or any color value |
backgroundColor | string | Background 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 | bool | Creates a pill style button |
big | bool | Creates a larger button |
ButtonCircle
A circular button suited for use with icons
<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>
Prop | Type | Description |
---|---|---|
href | string | Pass an href prop to make the ButtonCircle an <a> tag instead of a <button> |
color | string | Text color - can either be a key from the theme colors object or any color value |
backgroundColor | string | Background color - can either be a key from the theme colors object or any color value |
size | number | Sets width and height of button |
ButtonOutline
A general purpose outline style button element with customizable colors
<div> <ButtonOutline rounded="left"> Button </ButtonOutline> <ButtonOutline rounded={false} style={{marginLeft: -1}} > Group </ButtonOutline> <Button rounded="right" style={{marginLeft: -1}} > Button </Button> </div>
Variations
Prop | Type | Description |
---|---|---|
href | string | Pass an href prop to make the ButtonOutline an <a> tag instead of a <button> |
color | string | Text color |
rounded | oneOfType([bool, oneOf(['top', 'right', 'bottom', 'left'])]) | Controls the border radius for creating button groups |
pill | bool | Creates a pill style button |
big | bool | Creates a larger button |
Card
Styled box with border
<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>
Prop | Type | Description |
---|---|---|
width | oneOfType([number, string]) | Width of card |
CardImage
Image for use within the Card component
<div style={{maxWidth: 192}}> <CardImage src="http://placehold.it/320/08e/fff" /> </div>
Prop | Type | Description |
---|---|---|
src * | string | Image source |
Checkbox
Checkbox input with label
<Checkbox label="Checkbox" name="checkbox_example" />
Prop | Type | Description |
---|---|---|
label * | string | Label for form element |
name * | string | Name attribute for form element |
Close
A button with an × for close and dismiss actions
<Close />
Container
Div with max-width and margin auto for centering content
<Container> Container </Container>
Divider
Styled hr element
<div> <Divider /> <Divider ml={0} width={128} /> </div>
Prop | Type | Description |
---|---|---|
width | number | Sets a fixed width for stylistic options |
Donut
A single-value donut chart with percentage
<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>
Prop | Type | Description |
---|---|---|
value | number | Value from 0 to 1 |
size | number | Sets width and height |
strokeWidth | number | Sets width of stroke |
DotIndicator
Dot indicator buttons for use in carousels
<div> <DotIndicator active={0} length={3} onClick={function noRefCheck() {}} /> </div>
Prop | Type | Description |
---|---|---|
length | number | Number of dot buttons to show |
active | number | Index of the currently active dot |
onClick | func | Click event callback - returns index of clicked button |
Drawer
An off-canvas drawer component
<a href="demo"> See Demo Page </a>
Prop | Type | Description |
---|---|---|
size | number | Width or height of drawer, depending on placement |
open | bool | Shows and hides the drawer |
position | oneOf(['top', 'right', 'bottom', 'left']) | Position relative to the viewport |
onDismiss | func | Click event callback for the background overlay |
Dropdown
Position relative container for positioning DropdownMenu component
<Block> <Dropdown> <Button rounded={true}> Dropdown <Arrow direction="down" /> </Button> <DropdownMenu open={true}> <NavItem Component="a"> Hello </NavItem> <NavItem Component="a"> Hi </NavItem> </DropdownMenu> </Dropdown> </Block>
DropdownMenu
Absolutely positioned Menu component for use within Dropdown component
<a href="#Dropdown"> See Dropdown Example </a>
Prop | Type | Description |
---|---|---|
open | bool | Toggles visibility of DropdownMenu |
right | bool | Anchors menu to the right |
top | bool | Anchors menu to the top |
Embed
Responsive media embed wrapper
<Embed ratio={0.5625}> <iframe allowFullScreen={true} src="https://www.youtube.com/embed/KO_3Qgib6RQ" /> </Embed>
Prop | Type | Description |
---|---|---|
ratio | number | Aspect 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
Variations
Heading
Heading
Heading
Heading
Heading
Heading
Prop | Type | Description |
---|---|---|
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 |
HeadingLink
Heading element with unstyled link. Useful for in-page navigation
Prop | Type | Description |
---|---|---|
level | oneOf([1, 2, 3, 4, 5, 6]) | Heading level, e.g. level={1} for <h1> |
size | oneOf([1, 2, 3, 4, 5, 6]) | Visual size of heading |
href | string | href for link |
InlineForm
Inline grouped form for search or other simple forms
<InlineForm buttonLabel="Go" label="InlineForm" name="inline_form" onChange={function noRefCheck() {}} onClick={function noRefCheck() {}} />
Prop | Type | Description |
---|---|---|
label * | string | Input label |
name * | string | Input name |
value | oneOfType([number, string]) | Input value |
placeholder | string | Input placeholder |
onChange | func | onChange handler for input |
buttonLabel | string | Text for button |
onClick | func | onClick handler for button |
Input
Input element with label with support for aria-invalid, disabled, and readOnly HTML attributes
<Input label="Input" name="input_example" placeholder="Placeholder" rounded={true} type="text" />
Variations
Prop | Type | Description |
---|---|---|
label * | string | Label for form element |
name * | string | Name attribute for form element |
type | string | Form element type |
message | string | Adds a helper or error message below the input |
hideLabel | bool | Hides 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
Variations
Prop | Type | Description |
---|---|---|
label * | string | Label for form element |
name * | string | Name attribute for form element |
hideLabel | bool | Hides the form element label |
Label
Label element for form controls
<Label> Label for form elements </Label>
Prop | Type | Description |
---|---|---|
hide | bool | Accessibly hide label for use in high density UI. This can still cause accessibility issues. Use this with caution. |
LinkBlock
Unstyled display block link
LinkBlock
<LinkBlock Component="a" href="#LinkBlock" > <Media align="center" img="http://placehold.it/96/08e/fff" > <Heading level={3}> LinkBlock </Heading> </Media> </LinkBlock>
Prop | Type | Description |
---|---|---|
Component | node | Root component - useful for use with react-router's Link component |
Media
Media object with vertical alignment using flexbox
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
Prop | Type | Description |
---|---|---|
img | string | Image source |
right | bool | Displays image to the right |
align | oneOf(['top', 'center', 'bottom']) | Vertical alignment |
Menu
Menu component for navigation links and actions
<Menu> <NavItem Component="a"> Menu </NavItem> <NavItem Component="a"> NavItem </NavItem> <NavItem Component="a"> NavItem </NavItem> </Menu>
Message
Component for displaying flash and error messages
<Message type="success"> Hello Message! <Space auto={true} x={1} /> <Close /> </Message>
Variations
Prop | Type | Description |
---|---|---|
type | oneOf(['default', 'info', 'success', 'warning', 'error']) | Sets color based on type of message |
Overlay
Fixed positioned overlay for use with modal dialogs
<a href="demo"> See demo </a>
Prop | Type | Description |
---|---|---|
open | bool | Shows and hides overlay |
dark | bool | Sets dark transparent overlay style |
box | bool | Sets padding and background white for the content container |
fullWidth | bool | Sets content container full width |
onDismiss | func | Click event callback for the Overlay background |
PageHeader
Main page header with description
Page Header
Description about the page
<PageHeader description="Description about the page" heading="Page Header" />
Prop | Type | Description |
---|---|---|
heading | string | Page heading |
description | string | Description of page |
Panel
Panel for containing small pieces of information
Panels are great for visually separating UI, content, or data from the rest of the page.
<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
Prop | Type | Description |
---|---|---|
type | oneOf(['default', 'info', 'success', 'warning', 'error']) | Sets border color based on type of panel |
PanelHeader
Header for Panel component with vertical centering using flexbox
Variations
Prop | Type | Description |
---|---|---|
type | oneOf(['default', 'info', 'success', 'warning', 'error']) | Sets background color based on the type of panel |
Pre
Pre element for displaying code examples
const pre = { preformatted: 'text' }
<Pre> const pre = { preformatted: 'text' } </Pre>
Progress
Progress element
<Progress value={0.25} />
Prop | Type | Description |
---|---|---|
value | number | Value for progress bar |
Radio
Radio input with label
<Radio label="Radio" name="radio_example" />
Prop | Type | Description |
---|---|---|
label * | string | Label for form element |
name * | string | Name attribute for form element |
Rating
Star rating component with clickable buttons
<Rating value={3.5} />
Prop | Type | Description |
---|---|---|
value | number | Number of star rating from 1 to 5 |
onClick | func | Click handler - returns index of star clicked |
Section
Section element with vertical padding
<Section> Section </Section>
SectionHeader
Header for section elements
Section Header
With linked header
<Section> <SectionHeader description="With linked header" heading="Section Header" /> Section </Section>
Prop | Type | Description |
---|---|---|
heading | string | Section heading |
href | string | Link to section, used in HeadingLink |
description | string | Description of section |
Select
Select form control with label
<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
Prop | Type | Description |
---|---|---|
label * | string | Label for form element |
name * | string | Name attribute for form element |
options * | array | Options for select |
message | string | Adds a helper or error message below the select |
hideLabel | bool | Hides the form element label |
SequenceMap
Sequence map pattern for use in multi-step forms
<SequenceMap active={1} steps={[{children: 'Sign In', href: '#!'}, {children: 'Shipping Address', href: '#!'}, {children: 'Payment Method', href: '#!'}, {children: 'Place Order', href: '#!'}]} />
Prop | Type | Description |
---|---|---|
steps | array | Array of links for each step in the sequence |
active | number | Index of current step |
Space
Inline-block element for adding space between elements
<div> <Button rounded={true}> Button </Button> <Space x={1} /> <Button rounded={true}> With </Button> <Space x={4} /> <Button rounded={true}> Space </Button> </div>
Prop | Type | Description |
---|---|---|
x | oneOf([1, 2, 3, 4]) | Width of space based on the spacing scale |
auto | bool | Sets flex: 1 1 auto |
Stat
Styled number display for statistics
<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>
Prop | Type | Description |
---|---|---|
value | oneOfType([number, string]) | Value for stat shown in large font size |
unit | string | Optional unit for displaying next to value |
label | string | Label for stat |
topLabel | bool | Displays label above value |
Text
Component for displaying text in UI
Variations
Text
Text
Prop | Type | Description |
---|---|---|
small | bool | Sets a smaller font size |
Textarea
Textarea form element with label
Variations
Prop | Type | Description |
---|---|---|
label * | string | Label for form element |
name * | string | Name attribute for form element |
message | string | Adds a helper or error message below the textarea |
hideLabel | bool | Hides the form element label |
Toolbar
Toolbar component that vertically centers children with display flex
<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
Tooltip
<Tooltip title="Hello!"> <Heading level={3}> Tooltip </Heading> </Tooltip>
Prop | Type | Description |
---|---|---|
title | string | Text to display in tooltip |
Reflexbox
React flexbox layout and grid system
React Geomicons
React icon component for Geomicons