Skip to content

Commit 253b4f6

Browse files
authored
feat(table): add no-border-collapse prop and SCSS (#3987)
1 parent fca7bd5 commit 253b4f6

File tree

4 files changed

+79
-35
lines changed

4 files changed

+79
-35
lines changed

src/components/table/README.md

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -327,28 +327,29 @@ details.
327327

328328
`<b-table>` provides several props to alter the style of the table:
329329

330-
| prop | Type | Description |
331-
| ------------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
332-
| `striped` | Boolean | Add zebra-striping to the table rows within the `<tbody>` |
333-
| `bordered` | Boolean | For borders on all sides of the table and cells. |
334-
| `borderless` | Boolean | removes inner borders from table. |
335-
| `outlined` | Boolean | For a thin border on all sides of the table. Has no effect if `bordered` is set. |
336-
| `small` | Boolean | To make tables more compact by cutting cell padding in half. |
337-
| `hover` | Boolean | To enable a hover highlighting state on table rows within a `<tbody>` |
338-
| `dark` | Boolean | Invert the colors — with light text on dark backgrounds (equivalent to Bootstrap v4 class `.table-dark`) |
339-
| `fixed` | Boolean | Generate a table with equal fixed-width columns (`table-layout: fixed;`) |
340-
| `responsive` | Boolean or String | Generate a responsive table to make it scroll horizontally. Set to `true` for an always responsive table, or set it to one of the breakpoints `'sm'`, `'md'`, `'lg'`, or `'xl'` to make the table responsive (horizontally scroll) only on screens smaller than the breakpoint. See [Responsive tables](#responsive-tables) below for details. |
341-
| `sticky-header` | Boolean or String | Generates a vertically scrollable table with sticky headers. Set to `true` to enable sticky headers (default table max-height of `300px`), or set it to a string containing a height (with CSS units) to specify a maximum height other than `300px`. See the [Sticky header](#sticky-headers) section below for details. |
342-
| `stacked` | Boolean or String | Generate a responsive stacked table. Set to `true` for an always stacked table, or set it to one of the breakpoints `'sm'`, `'md'`, `'lg'`, or `'xl'` to make the table visually stacked only on screens smaller than the breakpoint. See [Stacked tables](#stacked-tables) below for details. |
343-
| `caption-top` | Boolean | If the table has a caption, and this prop is set to `true`, the caption will be visually placed above the table. If `false` (the default), the caption will be visually placed below the table. |
344-
| `table-variant` | String | Give the table an overall theme color variant. |
345-
| `head-variant` | String | Use `'light'` or `'dark'` to make table header appear light or dark gray, respectively |
346-
| `foot-variant` | String | Use `'light'` or `'dark'` to make table footer appear light or dark gray, respectively. If not set, `head-variant` will be used. Has no effect if `foot-clone` is not set |
347-
| `foot-clone` | Boolean | Turns on the table footer, and defaults with the same contents a the table header |
348-
| `no-footer-sorting` | Boolean | When `foot-clone` is true and the table is sortable, disables the sorting icons and click behaviour on the footer heading cells. Refer to the [Sorting](#sorting) section below for more details. |
349-
350-
**Note:** table style options `fixed`, `stacked`, and `caption-top`, and the table sorting feature,
351-
requires BootstrapVue's custom CSS.
330+
| prop | Type | Description |
331+
| -------------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
332+
| `striped` | Boolean | Add zebra-striping to the table rows within the `<tbody>` |
333+
| `bordered` | Boolean | For borders on all sides of the table and cells. |
334+
| `borderless` | Boolean | removes inner borders from table. |
335+
| `outlined` | Boolean | For a thin border on all sides of the table. Has no effect if `bordered` is set. |
336+
| `small` | Boolean | To make tables more compact by cutting cell padding in half. |
337+
| `hover` | Boolean | To enable a hover highlighting state on table rows within a `<tbody>` |
338+
| `dark` | Boolean | Invert the colors — with light text on dark backgrounds (equivalent to Bootstrap v4 class `.table-dark`) |
339+
| `fixed` | Boolean | Generate a table with equal fixed-width columns (`table-layout: fixed;`) |
340+
| `responsive` | Boolean or String | Generate a responsive table to make it scroll horizontally. Set to `true` for an always responsive table, or set it to one of the breakpoints `'sm'`, `'md'`, `'lg'`, or `'xl'` to make the table responsive (horizontally scroll) only on screens smaller than the breakpoint. See [Responsive tables](#responsive-tables) below for details. |
341+
| `sticky-header` | Boolean or String | Generates a vertically scrollable table with sticky headers. Set to `true` to enable sticky headers (default table max-height of `300px`), or set it to a string containing a height (with CSS units) to specify a maximum height other than `300px`. See the [Sticky header](#sticky-headers) section below for details. |
342+
| `stacked` | Boolean or String | Generate a responsive stacked table. Set to `true` for an always stacked table, or set it to one of the breakpoints `'sm'`, `'md'`, `'lg'`, or `'xl'` to make the table visually stacked only on screens smaller than the breakpoint. See [Stacked tables](#stacked-tables) below for details. |
343+
| `caption-top` | Boolean | If the table has a caption, and this prop is set to `true`, the caption will be visually placed above the table. If `false` (the default), the caption will be visually placed below the table. |
344+
| `table-variant` | String | Give the table an overall theme color variant. |
345+
| `head-variant` | String | Use `'light'` or `'dark'` to make table header appear light or dark gray, respectively |
346+
| `foot-variant` | String | Use `'light'` or `'dark'` to make table footer appear light or dark gray, respectively. If not set, `head-variant` will be used. Has no effect if `foot-clone` is not set |
347+
| `foot-clone` | Boolean | Turns on the table footer, and defaults with the same contents a the table header |
348+
| `no-footer-sorting` | Boolean | When `foot-clone` is true and the table is sortable, disables the sorting icons and click behaviour on the footer heading cells. Refer to the [Sorting](#sorting) section below for more details. |
349+
| `no-border-collapse` | Boolean | Disables the default of collapsing of the table borders. Mainly for use with [sticky headers](#sticky-headers) and/or [sticky columns](#sticky-columns). Will cause the appearance of double borders in some situations. |
350+
351+
**Note:** table style options `fixed`, `stacked`, `caption-top`, `no-border-collapse`, sticky
352+
headers, sticky columns, and the table sorting feature, all require BootstrapVue's custom CSS.
352353

353354
**Example: Basic table styles**
354355

@@ -365,6 +366,7 @@ requires BootstrapVue's custom CSS.
365366
<b-form-checkbox v-model="dark" inline>Dark</b-form-checkbox>
366367
<b-form-checkbox v-model="fixed" inline>Fixed</b-form-checkbox>
367368
<b-form-checkbox v-model="footClone" inline>Foot Clone</b-form-checkbox>
369+
<b-form-checkbox v-model="noCollapse" inline>No border collapse</b-form-checkbox>
368370
</b-form-group>
369371
<b-form-group label="Head Variant" label-cols-lg="2">
370372
<b-form-radio-group v-model="headVariant" class="mt-lg-2">
@@ -395,6 +397,7 @@ requires BootstrapVue's custom CSS.
395397
:dark="dark"
396398
:fixed="fixed"
397399
:foot-clone="footClone"
400+
:no-border-collapse="noCollapse"
398401
:items="items"
399402
:fields="fields"
400403
:head-variant="headVariant"
@@ -433,7 +436,8 @@ requires BootstrapVue's custom CSS.
433436
fixed: false,
434437
footClone: false,
435438
headVariant: null,
436-
tableVariant: ''
439+
tableVariant: '',
440+
noCollapse: false
437441
}
438442
}
439443
}
@@ -1249,9 +1253,8 @@ available horizontal space.
12491253
- BootstrapVue's custom CSS is required in order to support `sticky-header`.
12501254
- Bootstrap v4 uses the CSS style `border-collapse: collapsed` on table elements. This prevents the
12511255
borders on the sticky header from "sticking" to the header, and hence the borders will scroll when
1252-
the body scrolls. To get around this issue, create some custom CSS that targets
1253-
`table.table.b-table`, which sets they styles `border-collapse: separate; border-spacing: 0px;`
1254-
(note that this may cause double borders when using features such as `bordered`, etc).
1256+
the body scrolls. To get around this issue, set the pop `no-border-collapse` on the table (note
1257+
that this may cause double width borders when using features such as `bordered`, etc).
12551258
- The sticky header feature uses CSS style `position: sticky` to position the headings. Internet
12561259
Explorer does not support `position: sticky`, hence for IE11 the table headings will scroll with
12571260
the table body.
@@ -1269,8 +1272,17 @@ set.
12691272
```html
12701273
<template>
12711274
<div>
1272-
<b-form-checkbox v-model="stickyHeader" class="mb-2">Sticky header</b-form-checkbox>
1273-
<b-table :sticky-header="stickyHeader" responsive :items="items" :fields="fields">
1275+
<div class="mb-2">
1276+
<b-form-checkbox v-model="stickyHeader" inline>Sticky header</b-form-checkbox>
1277+
<b-form-checkbox v-model="noCollapse" inline>No border collapse</b-form-checkbox>
1278+
</div>
1279+
<b-table
1280+
:sticky-header="stickyHeader"
1281+
:no-border-collapse="noCollapse"
1282+
responsive
1283+
:items="items"
1284+
:fields="fields"
1285+
>
12741286
<!-- We are using utility class `text-nowrap` to help illustrate horizontal scrolling -->
12751287
<template v-slot:head(id)="scope">
12761288
<div class="text-nowrap">Row ID</div>
@@ -1289,6 +1301,7 @@ set.
12891301
data() {
12901302
return {
12911303
stickyHeader: true,
1304+
noCollapse: false,
12921305
fields: [
12931306
{ key: 'id', stickyColumn: true, isRowHeader: true, variant: 'primary' },
12941307
'a',
@@ -1335,13 +1348,12 @@ set.
13351348
previous sticky columns.
13361349
- Bootstrap v4 uses the CSS style `border-collapse: collapsed` on table elements. This prevents any
13371350
borders on the sticky columns from "sticking" to the column, and hence those borders will scroll
1338-
when the body scrolls. To get around this issue, create some custom CSS that targets
1339-
`table.table.b-table`, which sets they styles `border-collapse: collapsed; border-spacing: 0px;`
1340-
(note that this may cause double borders when using features such as `bordered`, etc).
1351+
when the body scrolls. To get around this issue, set the prop `no-border-collapse` on the table
1352+
(note that this may cause double width borders when using features such as `bordered`, etc).
13411353
- BootstrapVue's custom CSS is required in order to support sticky columns.
1342-
- The sticky column feature uses CSS style `position: sticky` to position the column cells.
1343-
- Internet Explorer does not support `position: sticky`, hence for IE11 the sticky column will
1344-
scroll with the table body.
1354+
- The sticky column feature uses CSS style `position: sticky` to position the column cells. Internet
1355+
Explorer does not support `position: sticky`, hence for IE11 the sticky column will scroll with
1356+
the table body.
13451357

13461358
### Row details support
13471359

src/components/table/_table.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
table-layout: fixed;
88
}
99

10+
// Disabled border-collapse
11+
// Mainly for use with sticky headers and columns
12+
&.b-table-no-border-collapse {
13+
border-collapse: separate;
14+
border-spacing: 0;
15+
}
16+
1017
// Table busy styling
1118
&[aria-busy="true"] {
1219
opacity: $b-table-busy-opacity;

0 commit comments

Comments
 (0)