Integrations
You can theme backpack UI components in several ways:
Global theming
Many EF products have their own set of colours for primary action buttons, form focus and suchlike. These can be set at the top level in whatever global css your site has, i.e:
_10:root {_10 --color-system-primary-accessible: teal;_10}
Now your buttons will look like this:
In case you don't want this override to apply to all components, we have added global classnames to all our components too.
The classnames follow the convention ef-{COMPONENTNAME}, so if you just wanted to change the primary accessible colour for buttons you could target:
_10.ef-button {_10 --color-system-primary-accessible: teal;_10}
Using CSS modules
If using CSS modules in your product, you can do something similar:
Using styled components
_21import styled from "styled-components";_21import {Button, ButtonGroup as BackpackButtonGroup} from "@ef-global/backpack/lib/components/Button";_21_21export const StyledComponents = () => {_21 const ButtonGroup = styled(BackpackButtonGroup)`_21 --color-system-primary-accessible: navy;_21 `_21 return (_21 <ButtonGroup>_21 <Button as={'button'} variant='primary'>_21 Primary_21 </Button>_21 <Button as={'button'} variant='secondary'>_21 Secondary_21 </Button>_21 <Button as={'button'} variant='link'>_21 Link_21 </Button>_21 </ButtonGroup>_21 )_21}
Using tailwind
You can also easily theme backpack components with a tailwind setup.
Inline
Due to css modules specificity, we advise that you use a prefix in your tailwind config.
For example, in nextjs, you can add the __next ID added to the <main> tag to provide further specificity.
Since our Button component has child components for the background and content (to ensure the button text is on a different layer to the background and the scale transitions look clean), in this case we can target the classes to the bgClassName and contentClassName props
_10<Button_10 as={'button'}_10 bgClassName={`bg-slate-600`}_10 contentClassName={'text-slate-100'}_10 variant="primary"_10>_10 Content_10</Button>