import ArrowLeft from '@govuk-frederic/arrow-left';
Simple
<ArrowLeft />
Dark background
import { GREY_1 } from 'govuk-colours';
const darkBackground = {
backgroundColor: GREY_1,
minHeight: '320px',
minWidth: '320px',
padding: '20px',
};
<div style={darkBackground}>
<ArrowLeft width={28} fill="white" />
</div>
Light background
import { WHITE } from 'govuk-colours';
const lightBackground = {
backgroundColor: WHITE,
minHeight: '320px',
minWidth: '320px',
padding: '20px',
};
<div style={lightBackground}>
<ArrowLeft width={28} fill="black" />
</div>
Dark background & title
import { GREY_1 } from 'govuk-colours';
const darkBackground = {
backgroundColor: GREY_1,
minHeight: '320px',
minWidth: '320px',
padding: '20px',
};
<div style={darkBackground}>
<ArrowLeft width={28} fill="white" color="white">
Back to previous page
</ArrowLeft>
</div>
Light background & title
import { WHITE } from 'govuk-colours';
const lightBackground = {
backgroundColor: WHITE,
minHeight: '320px',
minWidth: '320px',
padding: '20px',
};
<div style={lightBackground}>
<ArrowLeft width={28} fill="black">
Back to previous page
</ArrowLeft>
</div>
Wrapped with anchor with title text
import { WHITE } from 'govuk-colours';
const lightBackground = {
backgroundColor: WHITE,
minHeight: '320px',
minWidth: '320px',
padding: '20px',
};
<div style={lightBackground}>
<a href="http://example.com" style={{ color: '#005CA7' }}>
<ArrowLeft width={28} fill="black">
Back to previous page
</ArrowLeft>
</a>
</div>
Wrapped with anchor with title text on dark background
import { GREY_1 } from 'govuk-colours';
const darkBackground = {
backgroundColor: GREY_1,
minHeight: '320px',
minWidth: '320px',
padding: '20px',
};
<div style={darkBackground}>
<a href="http://example.com" style={{ color: 'white' }}>
<ArrowLeft width={28} fill="white">
Back to previous page
</ArrowLeft>
</a>
</div>
Passing down onClick with title text
import { GREY_1 } from 'govuk-colours';
const darkBackground = {
backgroundColor: GREY_1,
minHeight: '320px',
minWidth: '320px',
padding: '20px',
};
<div style={darkBackground}>
<ArrowLeft width={28} fill="white" onClick={action('clicked arrow button')}>
Back to previous page
</ArrowLeft>
</div>
Prop | Required | Default | Type | Description |
---|---|---|---|---|
children |
undefined |
string | ||
color |
undefined |
string | ||
fill |
BLUE |
string | ||
onClick |
undefined |
func | ||
width |
20 |
number |
import Arrow from '@govuk-frederic/arrow';
Simple
<Arrow />
Prop | Required | Default | Type | Description |
---|---|---|---|---|
fill |
'#0C60A2' |
string | ||
width |
20 |
number |
import CompactTableAccordionGroup from '@govuk-frederic/compact-table-accordion-group';
State managed with children
import manageState from 'manage-state';
const ManagedCompactTableAccordionGroup = manageState(CompactTableAccordionGroup, {
propsToState: ['open'],
});
<ManagedCompactTableAccordionGroup title="Title" expanded="expanded">
Children
</ManagedCompactTableAccordionGroup>
State managed without children
import manageState from 'manage-state';
const ManagedCompactTableAccordionGroup = manageState(CompactTableAccordionGroup, {
propsToState: ['open'],
});
<ManagedCompactTableAccordionGroup title="Title" expanded="expanded"/>
Toggle open on title click with 'changeOnTitleClick' prop
import manageState from 'manage-state';
const ManagedCompactTableAccordionGroup = manageState(CompactTableAccordionGroup, {
propsToState: ['open'],
});
<ManagedCompactTableAccordionGroup changeOnTitleClick title="Title" expanded="expanded">
Children
</ManagedCompactTableAccordionGroup>
Array
import manageState from 'manage-state';
const arrayExampleItems = ['Item 1', 'Item 2', 'Item 3', 'Item 4'];
const ManagedCompactTableAccordionGroup = manageState(CompactTableAccordionGroup, {
propsToState: ['open'],
});
<ManagedCompactTableAccordionGroup
expanded={
arrayExampleItems.map((item, index) => {
if (index) {
return <div>{item}</div>;
}
return null;
})}
>
{arrayExampleItems[0]}
</ManagedCompactTableAccordionGroup>
- Implement Async story example in CodeSandbox
Prop | Required | Default | Type | Description |
---|---|---|---|---|
changeOnTitleClick |
false |
bool | ||
children |
undefined |
node | ||
expanded |
true | `````` | node | |
onChange |
`````` | func | ||
open |
false |
bool | ||
title |
`````` | node |
import Count from '@govuk-frederic/count';
Simple
<Count value="5" />
Prop | Required | Default | Type | Description |
---|---|---|---|---|
textClass |
`````` | string | ||
value |
true | `````` | union(string | number) |
import CountdownTextArea from '@govuk-frederic/countdown-text-area';
Simple
import manageState from 'manage-state';
const ManagedCountdownTextarea = manageState(CountdownTextArea, {
changeEvent: true,
propsToState: ['value'],
});
<ManagedCountdownTextarea />
With maxlength (150)
import manageState from 'manage-state';
const ManagedCountdownTextarea = manageState(CountdownTextArea, {
changeEvent: true,
propsToState: ['value'],
});
<ManagedCountdownTextarea noMaxLengthAttr maxLength={150} />
With maxlength (100) and positiveOnly
import manageState from 'manage-state';
const ManagedCountdownTextarea = manageState(CountdownTextArea, {
changeEvent: true,
propsToState: ['value'],
});
<ManagedCountdownTextarea maxLength={100} positiveOnly />
Prop | Required | Default | Type | Description |
---|---|---|---|---|
maxLength |
undefined |
number | ||
noMaxLengthAttr |
false |
bool | ||
positiveOnly |
false |
bool |
import CounterBar from '@govuk-frederic/counter-bar';
Simple
<CounterBar>
<CounterBar.Total score={15}>All counters</CounterBar.Total>
<CounterBar.Counters>
<CounterBar.Counter score={1}>Counter 1</CounterBar.Counter>
<CounterBar.Counter score={2}>Counter 2</CounterBar.Counter>
<CounterBar.Counter score={3}>Counter 3</CounterBar.Counter>
<CounterBar.Counter score={4}>Counter 4</CounterBar.Counter>
<CounterBar.Counter score={5}>Counter 5</CounterBar.Counter>
</CounterBar.Counters>
</CounterBar>
Active counter
<CounterBar>
<CounterBar.Total score={15}>All counters</CounterBar.Total>
<CounterBar.Counters>
<CounterBar.Counter score={1}>Counter 1</CounterBar.Counter>
<CounterBar.Counter score={2}>Counter 2</CounterBar.Counter>
<CounterBar.Counter score={3} active>Counter 3</CounterBar.Counter>
<CounterBar.Counter score={4}>Counter 4</CounterBar.Counter>
<CounterBar.Counter score={5}>Counter 5</CounterBar.Counter>
</CounterBar.Counters>
</CounterBar>
Active total
<CounterBar>
<CounterBar.Total score={15} active>All counters</CounterBar.Total>
<CounterBar.Counters>
<CounterBar.Counter score={1}>Counter 1</CounterBar.Counter>
<CounterBar.Counter score={2}>Counter 2</CounterBar.Counter>
<CounterBar.Counter score={3}>Counter 3</CounterBar.Counter>
<CounterBar.Counter score={4}>Counter 4</CounterBar.Counter>
<CounterBar.Counter score={5}>Counter 5</CounterBar.Counter>
</CounterBar.Counters>
</CounterBar>
Empty counters
<CounterBar>
<CounterBar.Total score={7}>All counters</CounterBar.Total>
<CounterBar.Counters>
<CounterBar.Counter score={1}>Counter 1</CounterBar.Counter>
<CounterBar.Counter score={2}>Counter 2</CounterBar.Counter>
<CounterBar.Counter />
<CounterBar.Counter score={4}>Counter 4</CounterBar.Counter>
<CounterBar.Counter />
</CounterBar.Counters>
</CounterBar>
CounterBar with padded counters container
<div style={{padding: '4px'}}>
<CounterBar>
<CounterBar.Total score={15}>All counters</CounterBar.Total>
<CounterBar.Counters>
<CounterBar.Counter score={1}>Counter 1</CounterBar.Counter>
<CounterBar.Counter score={2}>Counter 2</CounterBar.Counter>
<CounterBar.Counter score={3}>Counter 3</CounterBar.Counter>
<CounterBar.Counter score={4}>Counter 4</CounterBar.Counter>
<CounterBar.Counter score={5}>Counter 5</CounterBar.Counter>
</CounterBar.Counters>
</CounterBar>
</div>
Zero/no scores
<CounterBar>
<CounterBar.Total score={9}>All counters</CounterBar.Total>
<CounterBar.Counters>
<CounterBar.Counter score={1}>Counter 1</CounterBar.Counter>
<CounterBar.Counter score={0}>Counter 2</CounterBar.Counter>
<CounterBar.Counter score={3}>Counter 3</CounterBar.Counter>
<CounterBar.Counter>Counter 4</CounterBar.Counter>
<CounterBar.Counter score={5}>Counter 5</CounterBar.Counter>
</CounterBar.Counters>
</CounterBar>
Custom colours on total
<CounterBar>
<CounterBar.Total score={15} scoreColor="yellow" scoreBackgroundColor="pink">All counters</CounterBar.Total>
<CounterBar.Counters>
<CounterBar.Counter score={1}>Counter 1</CounterBar.Counter>
<CounterBar.Counter score={2}>Counter 2</CounterBar.Counter>
<CounterBar.Counter score={3}>Counter 3</CounterBar.Counter>
<CounterBar.Counter score={4}>Counter 4</CounterBar.Counter>
<CounterBar.Counter score={5}>Counter 5</CounterBar.Counter>
</CounterBar.Counters>
</CounterBar>
Custom colours on counters
<CounterBar>
<CounterBar.Total score={15}>All counters</CounterBar.Total>
<CounterBar.Counters>
<CounterBar.Counter score={1}>Counter 1</CounterBar.Counter>
<CounterBar.Counter score={2} scoreColor="orange" scoreBackgroundColor="blue">Counter 2</CounterBar.Counter>
<CounterBar.Counter score={3}>Counter 3</CounterBar.Counter>
<CounterBar.Counter score={4} scoreColor="yellow" scoreBackgroundColor="purple">Counter 4</CounterBar.Counter>
<CounterBar.Counter score={5}>Counter 5</CounterBar.Counter>
</CounterBar.Counters>
</CounterBar>
Use any HTML element string for the total
<CounterBar>
<CounterBar.Total score={15} component="aside">All counters</CounterBar.Total>
<CounterBar.Counters>
<CounterBar.Counter score={1}>Counter 1</CounterBar.Counter>
<CounterBar.Counter score={2}>Counter 2</CounterBar.Counter>
<CounterBar.Counter score={3}>Counter 3</CounterBar.Counter>
<CounterBar.Counter score={4}>Counter 4</CounterBar.Counter>
<CounterBar.Counter score={5}>Counter 5</CounterBar.Counter>
</CounterBar.Counters>
</CounterBar>
Use a Link component for the total
import { HashRouter, Link } from 'react-router-dom';
<HashRouter>
<CounterBar>
<CounterBar.Total score={15} component={Link} to="/courses?sort=name'/">All counters</CounterBar.Total>
<CounterBar.Counters>
<CounterBar.Counter score={1}>Counter 1</CounterBar.Counter>
<CounterBar.Counter score={2}>Counter 2</CounterBar.Counter>
<CounterBar.Counter score={3}>Counter 3</CounterBar.Counter>
<CounterBar.Counter score={4}>Counter 4</CounterBar.Counter>
<CounterBar.Counter score={5}>Counter 5</CounterBar.Counter>
</CounterBar.Counters>
</CounterBar>
</HashRouter>
Use any HTML element string for a counter
<CounterBar>
<CounterBar.Total score={15}>All counters</CounterBar.Total>
<CounterBar.Counters>
<CounterBar.Counter score={1} component="nav">Counter 1</CounterBar.Counter>
<CounterBar.Counter score={2} component="aside">Counter 2</CounterBar.Counter>
<CounterBar.Counter score={3} component="div">Counter 3</CounterBar.Counter>
<CounterBar.Counter score={4} component="section">Counter 4</CounterBar.Counter>
<CounterBar.Counter score={5} component="span">Counter 5</CounterBar.Counter>
</CounterBar.Counters>
</CounterBar>
Use a Link component for a counter
import { HashRouter, Link } from 'react-router-dom';
<HashRouter>
<CounterBar>
<CounterBar.Total score={2}>All counters</CounterBar.Total>
<CounterBar.Counters>
<CounterBar.Counter score={1} component={Link} to="/courses/1/">Counter 1</CounterBar.Counter>
<CounterBar.Counter score={2}>Counter 2</CounterBar.Counter>
<CounterBar.Counter score={3}>Counter 3</CounterBar.Counter>
<CounterBar.Counter score={4}>Counter 4</CounterBar.Counter>
<CounterBar.Counter score={5}>Counter 5</CounterBar.Counter>
</CounterBar.Counters>
</CounterBar>
</HashRouter>
Prop | Required | Default | Type | Description |
---|---|---|---|---|
children |
true | `````` | node |
import DistractionFree from '@govuk-frederic/distraction-free';
Simple
<DistractionFree onClick={(e) => {}}>
content goes here
</DistractionFree>
With title
<DistractionFree arrowLeftTitle="Back to example" onClick={(e) => {}}>
content goes here
</DistractionFree>
Prop | Required | Default | Type | Description |
---|---|---|---|---|
arrowLeftTitle |
`````` | string | ||
children |
`````` | node | ||
onClick |
`````` | func |
import HeaderButton from '@govuk-frederic/header-button';
Simple
<HeaderButton>One</HeaderButton>
Multiple header buttons
<Fragment>
<HeaderButton>One</HeaderButton>
<HeaderButton>Two</HeaderButton>
</Fragment>
Multiple header buttons with keyline
<Fragment>
<Keyline>
<HeaderButton>One</HeaderButton>
<HeaderButton>Two</HeaderButton>
</Keyline>
</Fragment>
Active header button
<HeaderButton active>On</HeaderButton>
Disabled header button
<HeaderButton disabled>Off</HeaderButton>
Prop | Required | Default | Type | Description |
---|---|---|---|---|
active |
`````` | bool | ||
children |
`````` | node | ||
disabled |
`````` | bool |
import Keyline from '@govuk-frederic/keyline';
Simple
<Keyline>
<p>example</p>
</Keyline>
inlineBlock
<Keyline inlineBlock>
<p>example</p>
</Keyline>
inlineBlock with orange border
<<Keyline inlineBlock borderColor="#ff9900">
<p>example</p>
</Keyline>
Prop | Required | Default | Type | Description |
---|---|---|---|---|
borderColor |
`````` | string | ||
children |
`````` | node | ||
inlineBlock |
`````` | bool |
import OpenButton from '@govuk-frederic/open-button';
Simple
import manageState from 'manage-state';
const ManagedOpenButton = manageState(OpenButton, { propsToState: ['open']});
<ManagedOpenButton />
Prop | Required | Default | Type | Description |
---|---|---|---|---|
onChange |
`````` | func | ||
open |
`````` | bool |
import RemoveButton from '@govuk-frederic/remove-button';
Simple
<RemoveButton title="Remove" />
Next to some text
<div><span>Text here</span><RemoveButton title="Remove" /></div>
import ResultCountTitle from '@govuk-frederic/result-count-title';
Simple
<ResultCountTitle count={3}>Title</ResultCountTitle>
In black with count value 0
<ResultCountTitle count={0} countColor="black" countBackgroundColor="#dee0e2">Title</ResultCountTitle>
Prop | Required | Default | Type | Description |
---|---|---|---|---|
children |
`````` | node | ||
count |
`````` | union(number | string) | |
countBackgroundColor |
`````` | string | ||
countColor |
`````` | string |
import ResultCount from '@govuk-frederic/result-count';
Simple
<ResultCount>0</ResultCount>
Overriding background and text colours
<ResultCount backgroundColor="#6f777b" color="white">000</ResultCount>
Prop | Required | Default | Type | Description |
---|---|---|---|---|
backgroundColor |
GREY_1 |
string | ||
children |
undefined |
node | ||
color |
WHITE |
string |
import Spinner from '@govuk-frederic/spinner';
Simple
<Spinner visible />
Prop | Required | Default | Type | Description |
---|---|---|---|---|
visible |
`````` | bool |
import TableAccordionGroup from '@govuk-frederic/table-accordion-group';
State managed with children
import manageState from 'manage-state';
const ManagedTableAccordionGroup = manageState(TableAccordionGroup, {
propsToState: ['open'],
});
<ManagedTableAccordionGroup title="Title" expanded="expanded">
Children
</ManagedTableAccordionGroup>
State managed without children
import manageState from 'manage-state';
const ManagedTableAccordionGroup = manageState(TableAccordionGroup, {
propsToState: ['open'],
});
<ManagedTableAccordionGroup title="Title" expanded="expanded"/>
Toggle open on title click with 'changeOnTitleClick' prop
import manageState from 'manage-state';
const ManagedTableAccordionGroup = manageState(TableAccordionGroup, {
propsToState: ['open'],
});
<ManagedTableAccordionGroup changeOnTitleClick title="Title" expanded="expanded">
Children
</ManagedTableAccordionGroup>
Array
import manageState from 'manage-state';
const arrayExampleItems = ['Item 1', 'Item 2', 'Item 3', 'Item 4'];
const ManagedTableAccordionGroup = manageState(TableAccordionGroup, {
propsToState: ['open'],
});
<ManagedTableAccordionGroup
expanded={
arrayExampleItems.map((item, index) => {
if (index) {
return <div>{item}</div>;
}
return null;
})}
>
{arrayExampleItems[0]}
</ManagedTableAccordionGroup>
- Implement Async story example in CodeSandbox
Prop | Required | Default | Type | Description |
---|---|---|---|---|
changeOnTitleClick |
false |
bool | ||
children |
undefined |
node | ||
expanded |
true | `````` | node | |
onChange |
`````` | func | ||
open |
false |
bool | ||
title |
`````` | node |
import Table from '@govuk-frederic/table';
Simple
<Table titles={arrayExampleHeadings} rows={arrayExampleContent} names={exampleNames} />
rowIncludesHeading
<Table titles={arrayExampleHeadings} rows={arrayExampleContent} rowIncludesHeading />
rowIncludesHeading, no titles
<Table rows={arrayExampleContent} rowIncludesHeading names={exampleNames} />
rowIncludesHeading, no titles, small single row
<Table rows={[['title', 'value']]} rowIncludesHeading />
rowIncludesHeading, with flexible columns
<Table titles={arrayExampleHeadings} rows={arrayExampleContent} flexibleColumns rowIncludesHeading />
Prop | Required | Default | Type | Description |
---|---|---|---|---|
flexibleColumns |
`````` | bool | ||
name |
`````` | string | ||
names |
[] |
arrayOf[object Object] | ||
rowIncludesHeading |
`````` | bool | ||
rows |
true | `````` | arrayOf[object Object] | |
titles |
`````` | arrayOf[object Object] |
import TitleResultCount from '@govuk-frederic/title-result-count';
Simple
<TitleResultCount count={3}>
Title Title Title
</TitleResultCount>
Counter title with value 0 and override text and background colour.
<TitleResultCount count={0} countColor="black" countBackgroundColor="#dee0e2">
Title Title Title
</TitleResultCount>
Prop | Required | Default | Type | Description |
---|---|---|---|---|
children |
`````` | node | ||
count |
`````` | union(number | string) | |
countBackgroundColor |
`````` | string | ||
countColor |
`````` | string |