Applying AdapTable Style
Summary
- Format Columns can be given an AdapTable Style
- Styles can be either always rendered or when a Condition is met
- An AdapTable Style can set:
- Colours — text, cell background and border (plus an optional border radius)
- Font — weight, style, size and decoration
- Alignment — Left, Right or Center
- Alternatively a supplied CSS Class can be used
Format Columns in AdapTable can be provided with a Style which is used when the column is rendered.
This style can be one of 2 types:
- an AdapTable Style object
- a CSS Style
Hint
Use Conditional Styling when the style should apply only when a particular rule is met
AdapTable Style
Cells styled using Format Column leverage the Adaptable Style.
This will render all Scoped Cells in the Format Column (or those which meet the Condition, if one is set).
AdaptableStyle is composed of CellFontStyle (text), CellBoxStyle (cell chrome) and an optional ClassName:
| Property | Type | Description |
|---|---|---|
| ForeColor | string | Font colour in cell: hex, rgb(a) or name |
| FontWeight | 'Normal' | 'Bold' | Weight of font: Normal or Bold |
| FontStyle | 'Normal' | 'Italic' | Style of font: Normal or Italic |
| TextDecoration | 'None' | 'Underline' | 'Overline' | 'LineThrough' | Decoration of font: None, Underline, Overline or LineThrough |
| FontSize | 'XSmall' | 'Small' | 'Medium' | 'Large' | 'XLarge' | Size of font: XSmall, Small, Medium, Large or XLarge |
| Alignment | Alignment | Align to Left, Right or Center |
| BackColor | string | Colour background of cell: hex, rgb(a) or name |
| BorderColor | string | Colour of cell border: hex, rgb(a) or name |
| BorderRadius | number | Rounds corners of an element's outer border edge; equivalent of CSS border-radius |
| ClassName | string | CSS class added to the cell. Colour, font and border properties on this object are still applied. |
Hint
All properties are optional — set only those that should differ from the grid default
Find Out More
The Adaptable Style is used in a number of places in AdapTable where styling is required
Colours
You can set the colours for the text, background and (optional) border of the cell.
Style: {
ForeColor: 'var(--ab-color-palette-21)',
BackColor: '#2966a8',
BorderColor: '#80cbc4',
}Additionally you can set BorderRadius to configure the Border to your requirements.
Style: {
BorderRadius: 8,
}Find Out More
See Colour Properties for hex, name, rgb(a) and theme CSS variables
Font
The Font in the Cell is fully stylable via the FontWeight, FontStyle, FontSize and TextDecoration properties.
Note
TextDecoration values are mutually exclusive
Style: {
FontWeight: 'Bold',
FontStyle: 'Italic',
FontSize: 'Large',
TextDecoration: 'Underline',
}Alignment
Cell Alignment also lives in AdaptableStyle (i.e. it is not a separate Format Column setting).
Use Left, Right or Center to set the Alignment.
Style: {
Alignment: 'Center',
}Hint
Omitting Alignment, or setting Alignment: 'Default', leaves the column / grid default in place
- This example has 3 Format Columns provided which display a Column Style:
Nameis bold, large and underlinedLanguagehas a blue background, yellow text, a rounded teal border and is centre-aligned- all
Numbercolumns are italic
CSS Style
It is possible to apply existing CSS styles to the cell instead of defining the styles individually.
Hint
This is done by specifying the property ClassName which references a defined CSS class
Find Out More
See Setting CSS Style for Adaptable Style for more information
- This demo showcases applying external CSS classes to Format Columns:
- all numeric columns show the
rednumberCSS class - the
LanguageandLicensecolumns show thebluetextCSS class
- all numeric columns show the