The `TableStyles` class defines all of the base styles needed to style/theme a table. It defines the names of the styles that are used for styling the different parts of the table.
R6Class object.
countThe number of styles in this styles collection.
themeThe name of the theme.
stylesThe collection of `TableStyle` objects in this styles collection.
allowExternalStylesEnable integration scenarios where an external system is supplying the CSS definitions.
tableStyleThe name of the style for the HTML table element.
rootStyleThe name of the style for the HTML cell at the top left of the table (when both row and column headers are displayed).
rowHeaderStyleThe name of the style for the row headers in the table.
colHeaderStyleThe name of the style for the column headers in the table.
cellStyleThe name of the cell style for the non-total cells in the body of the table.
totalStyleThe name of the cell style for the total cells in the table.
new()Create a new `TableStyles` object.
TableStyles$new(parentTable, themeName = NULL, allowExternalStyles = FALSE)
parentTableOwning table.
themeNameThe name of the theme.
allowExternalStylesEnable integration scenarios where an external system is supplying the CSS definitions.
No return value.
isExistingStyle()Check whether a style with the specified name exists in the collection.
TableStyles$isExistingStyle(styleName = NULL)
styleNameThe style name.
`TRUE` if a style with the specified name exists, `FALSE` otherwise.
getStyle()Retrieve a style with the specified name from the collection.
TableStyles$getStyle(styleName = NULL)
styleNameThe style name.
A `TableStyle` object if a style with the specified name exists in the collection, an error is raised otherwise.
addStyle()Add a new style to the collection of styles.
TableStyles$addStyle(styleName = NULL, declarations = NULL)
styleNameThe style name of the new style.
declarationsA list containing CSS style declarations. Example: `declarations = list(font="...", color="...")`
The newly created `TableStyle` object.
copyStyle()Create a copy of an exist style.
TableStyles$copyStyle(styleName = NULL, newStyleName = NULL)
styleNameThe style name of the style to copy.
newStyleNameThe name of the new style.
The newly created `TableStyle` object.
asCSSRule()Generate a CSS style rule from the specified table style.
TableStyles$asCSSRule(styleName = NULL, selector = NULL)
styleNameThe style name.
selectorThe CSS selector name. Default value `NULL`.
The CSS style rule, e.g. text-align: center; color: red;
asNamedCSSStyle()Generate a named CSS style from the specified table style.
TableStyles$asNamedCSSStyle(styleName = NULL, styleNamePrefix = NULL)
styleNameThe style name.
styleNamePrefixA character variable specifying a prefix for all named CSS styles, to avoid style name collisions where multiple tables exist.
The CSS style rule, e.g. cell text-align: center; color: red;
asList()Return the contents of this object as a list for debugging.
TableStyles$asList()
A list of various object properties.
asJSON()Return the contents of this object as JSON for debugging.
TableStyles$asJSON()
A JSON representation of various object properties.
asString()Return the contents of this object as a string for debugging.
TableStyles$asString(seperator = ", ")
seperatorDelimiter used to combine multiple values into a string.
A character representation of various object properties.
clone()The objects of this class are cloneable with this method.
TableStyles$clone(deep = FALSE)
deepWhether to make a deep clone.
# Creating styles is part of defining a theme for a table. # Multiple styles must be created for each theme. # The example below shows how to create one style. # For an example of creating a full theme please # see the Styling vignette. tbl <- BasicTable$new() # ... TableStyles <- TableStyles$new(tbl, themeName="compact") TableStyles$addStyle(styleName="MyNewStyle", list( font="0.75em arial", padding="2px", border="1px solid lightgray", "vertical-align"="middle", "text-align"="center", "font-weight"="bold", "background-color"="#F2F2F2" ))