cf-ui is a set of packages used to build UIs at Cloudflare using projects such as React, Fela, Lerna and more. Read the introductory blog post! Interested in more of our technical decisions? See cf-ui/discussions. Whilst cf-ui is used extensively within Cloudflare, it is also an evolving set of components and therefore can be unstable. We reccommend only using this toolset to build interfaces for Cloudflare-internal products. However, feel free to follow along and contribute as we continue to grow this library
cf-ui uses CSS in JS and our components expect that there is Fela Renderer in the context of your React app. It's the way how to render styles that come with our components into the node. You have to use Fela in your project if you want to use cf-ui. Here's the code example how:
Do you want to try for yourself?
git clone git@github.com:cloudflare/cf-ui.git
cd cf-ui/example
yarn install
yarn run build
open index.html
Name | Type | Default value | Description |
---|---|---|---|
children | node |
Button group with spacing
Callout content.
Name | Type | Default value | Description |
---|---|---|---|
type | enum | One of: default, info | |
title | string | ||
content | node | required |
Here is some content.
Name | Type | Default value | Description |
---|---|---|---|
id | string | ||
children | node |
Name | Type | Default value | Description |
---|---|---|---|
children | node |
Name | Type | Default value | Description |
---|---|---|---|
children | node |
Name | Type | Default value | Description |
---|---|---|---|
onClick | func | ||
active | string | ||
drawers | custom | ||
controls | any |
Name | Type | Default value | Description |
---|---|---|---|
messages | shape[] | required | type: enum content: any |
Name | Type | Default value | Description |
---|---|---|---|
children | string |
Name | Type | Default value | Description |
---|---|---|---|
controls | any | ||
links | any |
Name | Type | Default value | Description |
---|---|---|---|
cardName | string | required | |
title | string | required | |
description | string | required | |
control | element | ||
table | element | ||
drawers | custom | ||
onDrawerClick | func | ||
activeDrawer | string |
You can create them individually with Checkbox
Or as a group with CheckboxGroup
You can also disable a label by passing false
explicitly
Name | Type | Default value | Description |
---|---|---|---|
label | union | required | One of type: string, enum |
name | string | required | |
value | string | required | |
checked | bool | required | |
onChange | func | required |
Name | Type | Default value | Description |
---|---|---|---|
values | string[] | required | |
onChange | func | required | |
options | shape[] | required | label: union name: string value: string |
Look at this inline code
!
And this code block!
Name | Type | Default value | Description |
---|---|---|---|
children | node |
Name | Type | Default value | Description |
---|---|---|---|
children | node |
Click to copy
Name | Type | Default value | Description |
---|---|---|---|
name | string | required | |
value | string | required | |
onCopy | func | ||
clickToCopyText | string | Click to copy | |
copiedTextToClipboardText | string | Copied text to clipboard | |
pressCommandOrCtrlCToCopyText | string | Press Command/Ctrl+C to copy |
Name | Type | Default value | Description |
---|---|---|---|
onClose | func | required | |
align | enum | left | One of: left, right |
children | node |
Name | Type | Default value | Description |
---|---|---|---|
to | string | ||
onClick | func | ||
children | node |
Name | Type | Default value | Description |
---|
Not an XSS attack, I swear.
Name | Type | Default value | Description |
---|---|---|---|
dangerouslySetInnerHTML | shape | required | __html: string |
Name | Type | Default value | Description |
---|---|---|---|
layout | enum | required | One of: horizontal, vertical |
onSubmit | func | required | |
children | node |
Name | Type | Default value | Description |
---|---|---|---|
field | object | required | |
validations | object | required |
Name | Type | Default value | Description |
---|---|---|---|
layout | enum | vertical | One of: horizontal, vertical |
styles | object | required | |
legend | string | required | |
children | node |
Name | Type | Default value | Description |
---|---|---|---|
title | string | required | |
styles | object | required |
Name | Type | Default value | Description |
---|---|---|---|
hidden | bool | ||
children | node |
Name | Type | Default value | Description |
---|---|---|---|
size | enum | required | One of: 1, 2, 3, 4, 5, 6 |
children | node |
Types:
Sizes:
Border:
Spin:
Muted:
White:
Name | Type | Default value | Description |
---|---|---|---|
label | union | required | One of type: string, enum |
type | enum | required | One of: bolt, calendar, caret-down, caret-left, caret-right, caret-up, chart, chevron-down, chevron-left, chevron-right, chevron-up, clipboard, close, drive, exclamation-sign, facebook, file, filter, flowchart, gear, googleplus, hamburger, happy, help, info-sign, linkedin, list, loading, lock, ok, ok-sign, pause, plus, refresh, remove, remove-sign, resize-horizontal, sad, search, shield, speech, time, twitter, upload, widen, wrench |
size | enum | One of: 2x, 3x, 4x, large, xlarge | |
border | bool | ||
spin | bool | ||
muted | bool | ||
white | bool | ||
role | string |
Name | Type | Default value | Description |
---|---|---|---|
type | enum | text | One of: text, email, number, password, search |
name | string | required | |
value | string | ||
defaultValue | string | ||
onChange | func | required | |
onKeyDown | func | ||
onBlur | func | ||
onFocus | func | ||
placeholder | string | ||
autoComplete | string | ||
disabled | bool |
DefaultInfoSuccessWarningError
Name | Type | Default value | Description |
---|---|---|---|
type | enum | required | One of: default, info, success, warning, error |
children | node |
Create a Link
with a to
prop:
Alternatively you can pass an onClick
handler:
Note: This will give it a role="button"
All additional props will be added to the Link
element:
You can even specify tagName
:
Name | Type | Default value | Description |
---|---|---|---|
to | string | ||
onClick | func | ||
tagName | string | a | |
disabled | bool | ||
children | node |
Basic usage:
Ordered list:
Name | Type | Default value | Description |
---|---|---|---|
children | node |
Name | Type | Default value | Description |
---|---|---|---|
children | node |
Name | Type | Default value | Description |
---|---|---|---|
children | node |
Name | Type | Default value | Description |
---|---|---|---|
type | enum | One of: confirm | |
isOpen | bool | required | |
onRequestClose | func | required | |
closeOnEsc | bool | true | |
closeOnBackdropClick | bool | true | |
children | node | ||
width | string |
Name | Type | Default value | Description |
---|---|---|---|
children | node |
Name | Type | Default value | Description |
---|---|---|---|
children | node |
Name | Type | Default value | Description |
---|---|---|---|
onClick | func | required | |
label | union | false | One of type: string, bool |
Name | Type | Default value | Description |
---|---|---|---|
children | node |
Name | Type | Default value | Description |
---|---|---|---|
children | node |
Name | Type | Default value | Description |
---|---|---|---|
type | enum | One of: success, error, info, warning | |
message | string | required | |
closable | bool | true | |
delay | number | 4000 | |
persist | bool | false | |
onClose | func | required |
Name | Type | Default value | Description |
---|---|---|---|
children | node |
Name | Type | Default value | Description |
---|---|---|---|
children | node |
Name | Type | Default value | Description |
---|---|---|---|
children | node |
Name | Type | Default value | Description |
---|---|---|---|
children | node |
Name | Type | Default value | Description |
---|---|---|---|
title | string | required | |
subtitle | string |
Name | Type | Default value | Description |
---|---|---|---|
info | string | ||
children | node |
Name | Type | Default value | Description |
---|---|---|---|
type | enum | required | One of: number, next, prev, ellipsis, loading, dot |
active | bool | ||
disabled | bool | false | |
children | node | ||
onClick | func |
Name | Type | Default value | Description |
---|---|---|---|
onPageChange | func | required | |
loading | bool | ||
totalCount | number | required | |
page | number | required | |
perPage | number | required | |
infoFormatter | func |
Name | Type | Default value | Description |
---|---|---|---|
active | string | required | |
onChange | func | required | |
steps | shape[] | required | id: string label: string disabled: bool |
You can create them individually with Radio
Or as a group with RadioGroup
You can also disable a label by passing false
explicitly
Name | Type | Default value | Description |
---|---|---|---|
label | union | required | One of type: string, enum |
name | string | required | |
value | string | required | |
checked | bool | required | |
onChange | func | required |
Name | Type | Default value | Description |
---|---|---|---|
children | node | ||
value | string | required | |
onChange | func | required | |
options | shape[] | required | label: union name: string value: string |
Name | Type | Default value | Description |
---|---|---|---|
disabled | bool | ||
label | string | ||
value | number | ||
options | array | ||
searchable | bool | false | |
multi | bool | false | |
onChange | func | ||
async | bool | false | |
creatable | bool | false |
One | Two | Three |
---|---|---|
1 | 2 | 3 |
4 | 5 | 6 |
7 | 8 | 9 |
Name | Type | Default value | Description |
---|---|---|---|
striped | bool | false | |
hover | bool | false | |
bordered | bool | true | |
condensed | bool | false | |
children | node |
Name | Type | Default value | Description |
---|---|---|---|
children | node |
Name | Type | Default value | Description |
---|---|---|---|
align | enum | One of: left, center, right | |
children | node |
Name | Type | Default value | Description |
---|---|---|---|
children | node |
Name | Type | Default value | Description |
---|---|---|---|
children | node |
Name | Type | Default value | Description |
---|---|---|---|
children | node |
Name | Type | Default value | Description |
---|---|---|---|
type | custom | default | |
accent | custom | false | |
children | node |
Name | Coolness | Update |
---|---|---|
James | 1 | |
David | -1 |
Name | Type | Default value | Description |
---|---|---|---|
tableName | string | required | |
rows | custom | ||
columns | custom | ||
striped | bool | ||
hover | bool | ||
bordered | bool | ||
condensed | bool | ||
flashes | object |
Name | Type | Default value | Description |
---|---|---|---|
onChange | func | required | |
active | string | required | |
tabs | shape[] | required | id: string label: string |
children | element[] | required |
Name | Type | Default value | Description |
---|---|---|---|
id | string | required | |
children | node |
Specify a size
and/or an align
and/or a type
and/or a case
Name | Type | Default value | Description |
---|---|---|---|
size | enum | One of: normal, small | |
weight | enum | normal | One of: normal, semi-bold, bold |
align | enum | One of: start, center, justify, end | |
type | enum | One of: info, success, warning, error, muted | |
case | enum | One of: capitalize, titlecase, lowercase, uppercase | |
children | node |
Example Toggle
Disabled
Name | Type | Default value | Description |
---|---|---|---|
label | union | required | One of type: string, enum |
name | string | ||
value | bool | ||
onChange | func | ||
onFocus | func | ||
onBlur | func | ||
disabled | bool |
Artboard: 16x16px. If you need to design for larger icons, scale up not down. If you scale up, your pixels will multiply and grow, ensuring that they'll be represented at larger sizes. If you scale down you may lose some pixels/details.
Export file type: SVG
Fill: #000000, 100% opacity
Artwork should be aligned in the center of the artboard. For icons that are "full-size" scale them appropriately so that they're visually balanced. For example, icons that are square will take up more volume than circular icons. You may want circular icons to have less padding than square icons.
Strokes and text must be converted to outlines. Text not converted to strokes will be rendered in a font specified by the browser.
As new icons get designed over time, it’s reasonable to expect that styles may diverge or vary even across the same set of icons. To accommodate for this inevitability there are some stylistic guidelines and principles that should be followed to support a more cohesive style even as new icons are designed. (These guidelines and principles too can change.)
Use geometric shapes and predictable/common angles wherever possible. Other than creating clean and pleasant looking icons, designing this way can reduce file size as fewer points are required to create the SVG path.
For system icons (not illustrations or artwork) keep details to a minimum and avoid gradients and multiple colors.
Although pixel-perfect stroke weights are not necessary, these weights are a good approximation to maintain visual balance.
For 16x16px icons:Icons can be used to add additional meaning to actions but they must be used very carefully. Icons can help overcome language barriers and provide additional context (users are already familiar with) to indicate clearly what action will be taken. Misused icons can confuse users.
Some things to keep in mind: