[docs] Add CSS-in-JS (e.g. Linaria) examples to docs
- Dominant language
- TypeScript
- Stars
- 10.9k
- Forks
- 543
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 101
Description
## Summary
It would be nice to see examples of components not only with `Tailwind` and `CSS Modules`, but also with a CSS-in-JS solution, like `linaria`/`next-yak`/`@emotion/styled`/`@compiled/react`/`styled-components`.
## Motivation
With this issue, I'm requesting approval to write all the examples similar to the one shown below. I can follow the conventions of this codebase to organize examples, but I need confirmation that such a PR would be welcome
## Example: `Accordion` component styled using `Linaria`
```tsx
import { Accordion } from '@base-ui/react/accordion'
import { css } from '@linaria/core'
import { styled } from '@linaria/react'
import type * as React from 'react'
export default function ExampleAccordion() {
return (
What is Base UI?
Base UI is a library of high-quality unstyled React components for
design systems and web apps.
How do I get started?
Head to the “Quick start” guide in the docs. If you’ve used unstyled
libraries before, you’ll feel at home.
Can I use it for my project?
Of course! Base UI is free and open source.
)
}
function PlusIcon(props: React.ComponentProps<'svg'>) {
return (
)
}
export const AccordionHeader = styled(Accordion.Header)`
margin: 0;
`
export const AccordionItem = styled(Accordion.Item)`
border-bottom: 1px solid var(--color-gray-200);
`
export const AccordionPanel = styled(Accordion.Panel)`
box-sizing: border-box;
height: var(--accordion-panel-height);
overflow: hidden;
color: var(--color-gray-600);
font-size: 1rem;
line-height: 1.5rem;
transition: height 150ms ease-out;
&[data-starting-style],
&[data-ending-style] {
height: 0;
}
`
export const AccordionRoot = styled(Accordion.Root)`
box-sizing: border-box;
display: flex;
width: 24rem;
max-width: calc(100vw - 8rem);
flex-direction: column;
justify-content: center;
color: var(--color-gray-900);
`
export const AccordionTrigger = styled(Accordion.Trigger)`
box-sizing: border-box;
position: relative;
display: flex;
width: 100%;
gap: 1rem;
align-items: baseline;
justify-content: space-between;
padding-block: 0.5rem;
padding-inline: 0.75rem 0.25rem;
color: var(--color-gray-900);
font-family: inherit;
font-weight: 500;
font-size: 1rem;
line-height: 1.5rem;
background: var(--color-gray-50);
border: none;
outline: none;
text-align: left;
@media (hover: hover) {
&:hover {
background-color: var(--color-gray-100);
}
}
&:focus-visible {
outline: 2px solid var(--color-blue);
z-index: 1;
}
`
export const TriggerIcon = styled(PlusIcon)`
box-sizing: border-box;
flex-shrink: 0;
width: 0.75rem;
height: 0.75rem;
margin-right: 0.5rem;
transition: transform 150ms ease-out;
[data-panel-open] > & {
transform: rotate(45deg) scale(1.1);
}
`
export const accordionContent = css`
padding: 0.75rem;
`
```
Contributor guide
Assessment
This issue has not been assessed yet.