mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 20:33:02 +00:00
docs(data-table): add "Custom column widths" example
This commit is contained in:
parent
9fcbf893cf
commit
a07265a350
2 changed files with 25 additions and 0 deletions
|
@ -328,6 +328,12 @@ title="Load balancers" description="Your organization's active load balancers."
|
|||
]}"
|
||||
/>
|
||||
|
||||
### Custom column widths
|
||||
|
||||
Specify a `width` or `minWidth` property in the `headers` object to customize the width of each column.
|
||||
|
||||
<FileSource src="/framed/DataTable/DataTableHeaderWidth" />
|
||||
|
||||
### Sticky header
|
||||
|
||||
Set `stickyHeader` to `true` for the header to be fixed in place.
|
||||
|
|
19
docs/src/pages/framed/DataTable/DataTableHeaderWidth.svelte
Normal file
19
docs/src/pages/framed/DataTable/DataTableHeaderWidth.svelte
Normal file
|
@ -0,0 +1,19 @@
|
|||
<script>
|
||||
import { DataTable } from "carbon-components-svelte";
|
||||
</script>
|
||||
|
||||
<DataTable
|
||||
headers="{[
|
||||
{ key: 'name', value: 'Name', width: '50%', minWidth: '200px' },
|
||||
{ key: 'protocol', value: 'Protocol', width: '60px' },
|
||||
{ key: 'port', value: 'Port', width: '60px' },
|
||||
{ key: 'rule', value: 'Rule', width: '10rem' },
|
||||
]}"
|
||||
rows="{Array.from({ length: 6 }).map((_, i) => ({
|
||||
id: i,
|
||||
name: 'Load Balancer ' + (i + 1),
|
||||
protocol: 'HTTP',
|
||||
port: i % 3 ? (i % 2 ? 3000 : 80) : 443,
|
||||
rule: i % 3 ? 'Round robin' : 'DNS delegation',
|
||||
}))}"
|
||||
/>
|
Loading…
Add table
Add a link
Reference in a new issue