SGUI / Development
Collapse
Host-owned visibility preserves children by default.
Loading examples…
Loading examples…
Examples
Loading examples…
Contains
No fixed SGUI child components.
Component documentation
SGUI / Development
Host-owned visibility preserves children by default.
Loading examples…
Loading examples…
Loading examples…
No fixed SGUI child components.
This section keeps child state while hidden.
Host-owned visibility preserves children by default.
This section keeps child state while hidden.
'use client';
import { useState } from 'react';
import { ThemeScope } from '@structured-growth/sg-ui/theme';
import { Collapse, Stack, Typography, Button } from '@structured-growth/sg-ui/experimental';
export default function CollapsePlaygroundExample() {
const [action, setAction] = useState("No action yet");
const [open, setOpen] = useState(false);
const [page, setPage] = useState(0);
const [pageSize, setPageSize] = useState(25);
const [selected, setSelected] = useState("overview");
return (
<>
<ThemeScope density="comfortable">
<Stack gap={3}><Button aria-expanded={open} onPress={() => setOpen(value => !value)}>Toggle details</Button><Collapse expanded={open} unmountOnCollapse={false}><Typography>{"This section keeps child state while hidden."}</Typography><Button>Read more</Button></Collapse></Stack>
</ThemeScope>
</>
);
}
The same props in independent density scopes.
This section keeps child state while hidden.
This section keeps child state while hidden.
'use client';
import { useState } from 'react';
import { ThemeScope } from '@structured-growth/sg-ui/theme';
import { Collapse, Stack, Typography, Button } from '@structured-growth/sg-ui/experimental';
export default function CollapsePlaygroundDensitiesExample() {
const [action, setAction] = useState("No action yet");
const [open, setOpen] = useState(false);
const [page, setPage] = useState(0);
const [pageSize, setPageSize] = useState(25);
const [selected, setSelected] = useState("overview");
return (
<>
<Stack gap={3}>
<ThemeScope density="compact"><Stack gap={3}><Button aria-expanded={open} onPress={() => setOpen(value => !value)}>Toggle details</Button><Collapse expanded={open} unmountOnCollapse={false}><Typography>{"This section keeps child state while hidden."}</Typography><Button>Read more</Button></Collapse></Stack></ThemeScope>
<ThemeScope density="comfortable"><Stack gap={3}><Button aria-expanded={open} onPress={() => setOpen(value => !value)}>Toggle details</Button><Collapse expanded={open} unmountOnCollapse={false}><Typography>{"This section keeps child state while hidden."}</Typography><Button>Read more</Button></Collapse></Stack></ThemeScope>
</Stack>
</>
);
}