2023:CSS Data Viewer Styling: Difference between revisions
Dgreenwood (talk | contribs) |
Dgreenwood (talk | contribs) |
||
| Line 1,604: | Line 1,604: | ||
|} | |} | ||
</tab> | </tab> | ||
:[[#Margin, Border, and Padding Styling Styling|Click here to return to the top of this tab.]] | |||
</tabs> | </tabs> | ||
Revision as of 14:47, 8 December 2022
The Grooper Web client's Review interface is styled using CSS (Cascading Style Sheets). This gives you a great deal of control over how Data Model elements appear and are laid out for a user during document review.
About
CSS is a style sheet language used to define how HTML elements appear visually. CSS style sheets are ubiquitous in the world of web design and development. Fonts, headers and other container elements can be styled to make a web page more visually appealing and and easier to read. How this content is separated and presented on a web page can be formatted using a CSS file.
In Grooper, you can style your Data Model with custom CSS. If you are using the Web Client, elements in your Data Model (Data Fields, Data Sections, etc.) are all rendered as some combination of HTML elements themselves when viewed over a browser. You can style how these elements are presented using CSS style sheets. This gives you a great deal of control over what you and your reviewers see during the Review activity.
| FYI |
The Review activity allows users to review various aspects of Grooper's automated document processing. What users review and how document content is presented is controlled by whichever Review Viewer UI the user is using.
|
|
|
|
|
|
|
|
Editing CSS at the Data Section and Data Table level can be particularly helpful when dealing with larger Data Models with multiple nested levels in their heirarchy. We will discuss this further in the Global Element Styling VS Local Element Styling section of this article. |
Basics
CSS styles webpage elements by defining a series of rules. Each rule defines how an HTML element looks: its text's font, its colors, its margins on the page, its alignment with other elements and more.
|
|
In our case, the HTML elements we're working with correspond to our Data Model's Data Elements. The Data Fields, Data Sections, and Data Tables in the Data Model are rendered in a browser by a combination of HTML elements and their sub-elements. Each different kind of Data Element has a corresponding CSS class that can be custom styled.
|
For example, when a user operates the Data Viewer in the Review activity and looks at a Data Field, they're really seeing three total HTML elements.
|
|
|
|
|
|
|
|
.DataField label {
color: rgb(248,148,32);
font-size: 18px;
}
The selector
The declaration block defines how we want to style the element.
|
|
|
No styling was applied to the:
We would need to make separate CSS rules to style these elements as we wish. |
| FYI |
|
A Common Example: Increasing a Data Field's Label Width
|
It's not just about making things "look good". If the Data Model is easier to read, it's easier to understand. This makes the Review experience more efficient, ultimately making the process quicker and even preventing costly data entry errors. |
|
|
Here, we've changed the CSS styling to increase the width of all Data Field labels in the Data Model to 132 pixels wide, using the following rule: .DataField label {
width: 132px;
}
Now, the label widths for all Data Fields have been lengthened to 132 pixels. As a result, the Data Model is much easier to read and interact when operating the Data Viewer during a Review activity. |
Styling Scope: Selecting Data Elements
In the previous examples, we styled Data Fields in a global manner. The CSS rule was applied to all Data Fields in the Data Model. Sometimes we want to be more specific. We may want to narrow a rule's scope so that it is applied to some elements, but not others.
Narrowing down the styling scope is done using one, or both, of the following methods:
- Selecting a specific Data Element using it's name.
- For example, selecting and styling a Data Field named "SSN" rather than all Data Fields.
- Selecting a Data Element's children or sibling elements.
- For example, selecting and styling Data Fields in a Data Section rather than all Data Fields.
- This is done using what are called "combinators" in CSS.
Styling Named Elements
Imagine you have a specific Data Field you want to draw your users attention to. This may be a more "important" field according to some process if your organization that you really want them to pay attention to. One thing you could do is change the label's color to make it more distinct from the other fields in your Data Model.
To do this, you would select the specific element by name, rather than selecting all Data Fields.
|
We're going to style just this Data Field with CSS. All we need to do is select the Data Field by name. Instead of using |
|
|
.Hire_Date label {
color: rgb(248,148,32)
}
|
|
|
.DataField label {
width: 132px;
color: rgb(54,176,167)
}
.Hire_Date label {
color: rgb(248,148,32)
}
|
|
|
|
Selecting Multiple Elements
You can select and style multiple elements by creating a comma separated list of elements in the selector.
|
.Hire_Date label,
.Zip label,
.Phone label {
color: rgb(248,148,32);
}
|
| FYI |
You can also list elements horizontally, the two CSS rules below will operate identically.
However, most would agree a vertical comma separated list of selectors is more readable. |
Intro to Combinators
Styling child and sibling elements can be a great way to add more specificity to how you want to style various Data Elements in your Data Model. Child and sibling elements are selected in CSS using a "combinator".
A combinator explains the relationship between selectors. A combinator character is placed between selectors to define the relationship.
- i.e.
<element1><combinator><element2>
There are four combinators in CSS:
- All descendant children selector>- Immediate children selector+- Adjacent (meaning "first immediately following") sibling selector~- General (meaning "all following") sibling selector
|
|
When styling the width or the color of Data Fields' labels we used the following selector:
.DataField label
The space character between .DataField and label is the descendent children selector. So, by selecting .DataField label we were selecting the child label elements of all .DataField elements.
- This means any styling we applied was done not to the larger
.DataFieldelement (representing the Data Field) but instead all descendent childrenlabelelements (representing the Data Field's label).
| FYI |
While technically |
Next, we'll look at other ways to use combinators.
Styling Child Elements
By far, the most common combinators you will likely use are the children combinators. This will allow you to utilize Data Sections in ways to define styles for a particular collection of Data Elements distinct from the Data Model as a whole or Data Elements in other Data Sections.
- The
(a single space character) selects all descendant children. - The
>selects only immediate children.
|
|
Descendent Children Combinator
|
.Address_Info .DataField label {
color: rgb(248,148,32);
}
See here, only the Data Fields in the "Address Info" Data Section had their label text colored orange. The selector
|
|||
|
Let's imagine we have a Data Section within a Data Section.
|
|||
|
|
Immediate Children Combinator
|
|
|||
|
.Address_Info > .DataField label {
color: rgb(248,148,32);
}
|
Styling Sibling Elements
Less commonly, you may want to style sibling elements using the sibling combinators. This is a way of styling sibling Data Elements (existing in the same level of your Data Model's hierarchy) that come after a selected element.
- The
+selects "adjacent" siblings, selecting a single element after a specified element.- Put another way, the first instance of an element after a specific element.
- The
~selects "general" siblings, selecting any and all elements after a specified element.- Put another way, all instances of an element after a specific element.
|
|
|
|
|
|
|
.Address_Info + .DataField label {
color: rgb(248,148,32);
}
|
|
|
.Address_Info ~ .DataField label {
color: rgb(248,148,32);
}
|
Summary
|
Selection Type |
CSS Rule |
Selected Data Elements |
Data View Result |
|
|
.DataField label {
color: rgb(248,148,32);
}
Selects every Data Field's label and colors it orange. |
||
|
|
.Hire_Date label {
color: rgb(248,148,32);
}
Selects only the "Hire Date" Data Field's label and colors it orange. |
||
|
|
.Address_Info .DataField label {
color: rgb(248,148,32);
}
Selects the Data Fields' labels for all children at every descendent level in the "Address Info" Data Section and colors them orange. |
||
|
|
.Address_Info > .DataField label {
color: rgb(248,148,32);
}
Selects the Data Fields' labels only for children in the first level in the "Address Info" Data Section and colors them orange. |
||
|
|
.Address_Info + .DataField label {
color: rgb(248,148,32);
}
Selects the first sibling Data Field's label after the "Address Info" Data Section and colors it orange.
|
||
|
|
.Address_Info ~ .DataField label {
color: rgb(248,148,32);
}
Selects all sibling Data Fields' labels after the "Address Info" Data Section and colors them orange.
|
Selector Quick Reference
|
Selector |
Data Element Selection Information |
|
|
Selects Data Fields |
|
|
Selects single-instance Data Sections
|
|
|
Selects multi-instance Data Sections
|
|
|
Selects Data Tables |
|
|
Selects Data Columns |
|
|
The
|
|
|
|
|
|
This is the easiest selector to select all Data Column labels.
|
|
|
|
|
|
Textboxes for multiline Data Fields are rendered as a content editable
|
|
|
|
|
|
|
Types of Styling Available
There is A LOT you can do with CSS. There's far too much for us to cover completely. However, there are a few common types of styling you may want to apply to your Data Model.
In this section, we will detail some basic examples as they relate to the following categories:
Font and Text Styling
Font and text formatting are some of most basic, but also most important, considerations when building a website. We will review a few of the standard CSS properties that can alter the text labels in a Data Model.
|
|
The font-size property will adjust the size (height) of the font. Font size can be adjusted using absolute values or relative values.
|
.Hire_Date label {
font-size: 21px;
}
|
You can also set the font size relatively by setting the font size as a percent or with an "em" value.
- 1em = the current font size. Therefore 0.5em = half the current font size. 2em = double the current font size. And so on.
- Many developers prefer to use relative sizing as it tends to work better across all browsers and consider using em values to be best practice.
The default size of Data Field labels is set to 14px in Grooper. Therefore, the following CSS rules should produce identical results:
.Hire_Date label {
font-size: 21px;
}
|
.Hire_Date label {
font-size: 1.5em;
}
|
.Hire_Date label {
font-size: 150%;
}
|
The font-style allows you to italicize text.
|
.Hire_Date label {
font-style: italic;
}
|
The font-style property may be set to one of the following:
- normal
- italic
- oblique
If no italic or oblique face for the font is available, the browser will attempt to mimic the sloping effect. If italic is selected, but there is no italic face for the selected font, the browser will attempt to use the oblique face before mimicking effect (and visa versa if oblique is selected).
| FYI |
What's the difference between italic and oblique? Good question. The short answer is "not much".
|
The font-weight property allows you to bolden or lighten text (when available).
|
.Hire_Date label {
font-weight: bold;
}
|
The font-weight property may be set to one of the following:
- normal
- bold
- bolder
- lighter
If selected and the font being used has a "bold" or "normal" version, the browser will use that. If not, it will attempt to mimic a bold or normal version. The browser will not attempt to mimic a "lighter" or "bolder" version if none are found.
The font-variant property allows you format your text in small caps.
|
.Hire_Date label {
font-variant: small-caps;
}
|
The font-variant property may be set to either of the following:
- normal
- small-caps
The font-family property sets what font family should be used to render the text.
|
.Hire_Date label {
font-family: Courier New;
}
|
Be aware a font will only display if it is installed by the browser or on the device viewing the webpage. The following fonts are considered "web-safe". These are fonts universally installed by all browsers.
(Generally) Web-Safe Fonts
- Arial (sans-serif)
- Verdana (sans-serif)
- Tahoma (sans-serif)
- Trebuchet MS (sans-serif)
- Times New Roman (serif)
- Georgia (serif)
- Garamond (serif)
- Courier New (monospace)
- Brush Script MT (cursive)
However, there are no 100% web safe fonts. While these are "universally" installed across "all" browsers, there's always a chance the font is not installed properly or is otherwise missing. That's why it's best practice to use a fallback font.
- Fallback fonts are separated using a comma.
- For example:
font-family: Tahoma, Verdana, sans-serif;- The browser would first attempt to use Tahoma.
- If that font cannot be found, it then attempts to use Veranda.
- If that font cannot be found it will use the generic system sans-serif font for the browser.
AT BARE MINIMUM, you should always include one of the following generic fallback fonts when declaring a font family:
- sans-serif
- serif
- monospace
- cursive
- fantasy
The text-align property allows you to set an alignment for text inside the element.
|
.Hire_Date label {
text-align: right;
}
|
You may choose one of the following alignments:
- left (This is the default, in most cases)
- right
- center
- justify
As we've seen in previous examples, the color property styles the element's text content's color.
|
.Hire_Date label {
color: rgb(248,148,32);
}
|
Colors can help draw a user's attention and separate content in meaningful ways. There's also more to coloring a webpage than just coloring text. We'll talk more about color styling in the Color Styling section of this article.
|
Text Style |
CSS Rule |
Selected Data Elements |
Data View Result |
|
|
.Hire_Date label {
font-size: 21px;
}
Increases the "Hire Date" Data Field's font size to 21 pixels high. |
||
|
|
.Hire_Date label {
font-style: italic;
}
Italicizes the "Hire Date" Data Field's label. |
||
|
|
.Hire_Date label {
font-weight: bold;
}
Bolds the "Hire Date" Data Field's label. |
||
|
|
.Hire_Date label {
font-variant: small-caps;
}
Turns the "Hire Date" Data Field's label to small caps. |
||
|
|
.Hire_Date label {
font-family: Courier New, monospace;
}
Changes the "Hire Date" Data Field from the default font (Open Sans) to Courier New. If Courier New cannot be rendered, the system monospace font will be used as a fallback font. |
||
|
|
.Hire_Date label {
text-align: right;
}
Right aligns the "Hire Date" Data Field's text within its |
||
|
|
.Hire_Date label {
color: rgb(248,148,32);
}
Changes the "Hire Date" Data Field's label's text color to "Grooper orange", using the RGB color value. |
Styling Data Section and Data Table Caption Labels
|
When it comes to styling Data Section and Data Table captions, you'll need to use the
|
|||
|
.caption {
color: rgb(248,148,32);
font-size: 1.75em;
font-variant: small-caps;
}
|
|||
|
.DataTable .caption {
color: rgb(248,148,32);
font-size: 1.75em;
font-variant: small-caps;
}
|
|||
|
For example, the following CSS rule would remove the caption for any child Data Section in the "Address Info" section. .Address_Info .DataSection .caption {
display: none;
}
|
Margin, Border, and Padding Styling
There's good reason why a div HTML element is named so. A div creates a division within a document, making it more distinct from other elements on the webpage. Margins, borders and padding help make the divisions between HTML elements visually more distinct by increasing the space between the elements (margins), outlining the elements (borders) and increasing the space within an element (padding).
Effective use of margins, borders and padding can increase the readability and accessibility of your Data Model when viewed in a Review viewer.
|
This diagram is designed to help you better understand the different dimensions of an HTML element, including:
|
|||
|
|
|
|
|
|
.DataSection {
margin-left: 24px;
}
|
|
|
.DataTable {
margin-left: auto;
margin-right: auto;
}
|
|
|
|
|
.DataTable {
border: 1px solid;
}
|
|
|
.DataSection {
border: 1px solid;
}
There is effectively no padding specified here. As it stands, having a border around Data Sections doesn't visually improve the Data Model. This doesn't really do anything to improve the users experience in Review and, frankly, looks bad. Next, we will add some padding to these elements to vastly improve the Data Sections' styling. |
|
|
|
|
Below, the CSS rule adds a 1 pixel border around Data Sections and increases their padding by 12 pixels on all sides. .DataSection {
border: 1px solid;
padding: 12px;
}
See here, the space between the element and the border are better spaced out. 12 pixels have been added to the top, bottom, left and right edges to the element, between the 1 pixel wide solid border. |
|
|
.DataSection {
border: 1px solid;
padding: 12px;
border-radius: 5px;
}
|
|
|
|
|
|
|
|
|
|
|
.DataSection {
border: 1px solid;
padding: 12px;
max-width: 400px;
}
The result is a much cleaner, more readable collection of Data Sections on the page. |
|
|
.DataSection {
border: 1px solid;
padding: 12px;
width: 400px;
}
There are plenty of circumstances in which the literal |
|
There is one element width you cannot adjust with CSS, an
|
|
Style Description |
CSS Rule |
Selected Data Elements |
Data View Result |
|
|
.DataSection {
margin-left: 24px;
}
Adds 24 pixels to all Data Sections' left margin. Effectively, this left indents all Data Section elements 24 pixels.
|
||
|
|
.DataTable {
margin-left: auto;
margin-right: auto;
}
Sets all Data Tables' left and right margins to |
||
|
|
.DataSection {
border: 1px solid;
}
Outlines all Data Sections with a 1 pixel wide border. |
||
|
|
.DataSection {
border: 1px solid;
padding: 12px;
}
Outlines all Data Sections with a 1 pixel wide border. Adds 12 pixels of padding between the element's content and the border. |
||
|
|
.DataSection {
border: 1px solid;
padding: 12px;
border-radius: 5px;
}
Outlines all Data Sections with a 1 pixel wide border. Adds 12 pixels of padding between the element's content and the border. Rounds the corners on the borders. |
||
|
|
.DataSection {
border: 1px solid;
padding: 12px;
width: 400px;
}
Outlines all Data Sections with a 1 pixel wide border. Adds 12 pixels of padding between the element's content and the border. Sets the literal width of all Data Section elements to 400 pixels wide. |
||
|
|
.DataSection {
border: 1px solid;
padding: 12px;
max-width: 400px;
}
Outlines all Data Sections with a 1 pixel wide border. Adds 12 pixels of padding between the element's content and the border. Sets the maximum width of all Data Section elements to 400 pixels wide. |
Color Styling
Colors are useful in a variety of different ways. They don't just "look pretty". They're used to call attention to different portions of a document, divide sections on a document, or distinguish between portions of a document.
There are a lot of ways you could style elements' colors in HTML (and therefore Data Elements in Grooper's Data Viewer). We're going to focus on the three most common ways colors are styled:
- Text colors
- Border colors
- Background colors
First, how do you pick a color? How do you define whether something is red or blue or hot pink? There are a few different ways to define a color value in CSS.
You can specify colors in CSS in the following ways:
|
#FFF8DC |
Hexadecimal colors
|
|
#FFF8DC50 |
Hexadecimal colors with transparency
|
|
rgb(255, 239, 213) |
RGB colors
|
|
rgba(255, 239, 213, .5) |
RGBA colors
|
|
hsl(36, 100%, 84%) |
HSL colors
|
|
hsla(36, 100%, 84%, .5) |
HSLA colors
|
|
BurlyWood |
Predefined color names used across browsers
|
| ⚠ |
Which color space should you use? RGBA should be your default choice.
|
We've already seen text color styling in this article, using the color property. The color property change the text's color within an element.
|
For example, this CSS rule will color the "Employee Name" Data Field's input box text yellow. .Employee_Name input {
color: rgba(255,255,50,1)
}
Something like this can be useful for a Data Field value that needs highlighting. If a user has a need to keep referencing an extracted value, this will more clearly call it out in the Review viewer. |
You can style a border's color using either the border-color or border property.
|
If the HTML element already has a border specification, you can use the This CSS rule recolors the border around the "Employee Name" Data Field's input box. .Employee_Name input {
border-color: rgba(248,148,32,1);
}
Please note, if the element doesn't already have a border specified (either from an inherited class or in the CSS rule itself), the |
|
|
You can use the The first description line in the following CSS rule creates the border, including coloring it orange with the RGBA color .DataSection {
border: 1px solid rgba(248,148,32,1);
border-radius: 5px;
padding: 12px;
max-width: 400px;
}
|
Text is considered the "foreground" of an HTML element. Whatever is behind it counts as "background". The background-color property (appropriately enough) colors an element's background. Coloring an element's background can be a great way of drawing attention to certain Data Elements or making visual breaking points between groups of Data Elements.
|
This CSS rule colors the background of the "Employee Name" Data Field's input box yellow. This is another way to make an important field stand out from others. .Employee_Name input {
background-color: rgba(255,255,50,1);
color: rgba(0,0,0,1);
}
Notice we also changed the text color to black (
|
|
|
Background color styling is also a great way to make your Data Sections distinct.
.DataSection {
background-color: rgba(0,0,0,.3);
border: 1px solid rgba(255,255,255,.5);
border-radius: 5px;
padding: 8px;
max-width: 400px;
margin-top: 8px;
}
The combination of borders, padding and color shading really separates these Data Sections from the rest of the Data Model. |
| FYI |
Please be aware any padding in an element is considered part of the element's background. As such, space specified by padding will be colored by a
|
Layout Styling (and Mirroring a Document's Layout)
Without CSS, you'd have no control over how Data Elements are laid out in the Data Viewer. They would appear on the screen essentially as a list, with each Data Field occupying a single line. However, CSS rules give you a great deal of flexibility in terms of laying out the various elements that make up the Data Elements in your Data Model.
|
Using Data Sections to better group and organize sections of Data Fields and using CSS to style those Data Sections and Fields, you can get pretty close to the same layout in the Data Viewer screen in Review as you have on the page. This can be a tremendous boon to document reviewers. If the entry fields are laid out like are on the actual document, they don't have to do nearly as much searching for what they're trying to enter. Ultimately, this saves time on data entry and can reduce error rates as well. |
We describe this kind of Data Model styling as a "Mirrored Layout". The Data Model is styled to mirrors how fields, sections and tables are laid out on the physical document itself. Going from the basic "List & Card Layout" to a "Mirrored Layout" is all about styling where and how HTML elements appear next to one another in the browser.
|
|
anchor text"
Before even touching CSS, you should think about organizing your Data Model to better lay out Data Elements in the Review Viewer. Data Sections can be extraordinarily beneficial to this end.
A Data Section can act as a simple bucket to hold other Data Elements to better organize your Data Model. They will also act as a parent HTML element holding the Data Elements. You can use CSS to physically constrain the Data Section's child elements in the browser, order a collection of elements on top of or to the side of other Data Sections and their elements. You can also use children selectors to style just the elements within a specific Data Section, distinct from the typical styling for the rest of the Data Model.
|
|
|||
|
We have adjusted our Data Model to reflect these divisions by adding some Data Sections.
|
|||
|
For instance, we goofed.
|
|||
|
For example,
|
To understand how HTML elements are laid out on a webpage, you need to have a concept of "inline" and "block" elements (as well as a special type of inline element called "inline-block").
|
Block elements always start on a new line.
|
|
|
Inline elements do not start on a new line.
|
|
|
Specifically, Inline-block elements do not start on a new line, but you can adjust the width and height of the element.
|
|
|
Getting our Data Model to look more like the document's layout has a lot to do with manipulating the inline and block modes using the On our document, several of the fields' labels are stacked vertically on top of the value. We can replicate this layout by simply changing our Data Fields' The rule below will accomplish this goal: .DataField * {
display: block;
}
FYI: The |
|
|
On the document, fields are laid out horizontally next to each other, rather than being stacked vertically on top of each other. Because Data Fields are block elements by default, our Data Fields have more of a vertical layout. To get a more of a horizontal layout, we can simply change their display mode to inline-block. This will allow multiple Data Fields to be displayed across a single line. Adding the rule below will accomplish this goal: .DataField {
display: inline-block;
}
|
|
|
What about this section of fields on the document? Their layout is different from the rest of the document. The layout is actually more like the default Data Field styling. What can we do to fix this? |
|
|
Adding, the following CSS rules will suffice: .Additional_Info .DataField {
display: block;
}
.Additional_Info .DataField * {
display: inline-block;
}
|
|
|
|
| FYI |
We did two things to make our Data Model more closely mirror the document's layout:
.DataField * {
display: block;
}
.DataField {
display: inline-block;
}
While there are certainly differences between these various display modes and CSS rules, the end result as far as our purposes in using CSS to style a Data Model for view during Review are often similar (if not identical). |
Styling your Data Elements dimensions can be an effective way to help your Data Model mirror your document's layout. Sometimes this boils down to nothing more than adjusting the width of your Data Field's input elements.
|
|
|
|
|
|
|
It doesn't really make sense for all our Data Fields' labels to be a set width now that most of them have a different layout orientation.
|
|
|
.DataField label{
width: 132px;
}
In reality, the only .Additional_Info .DataField label{
width: 132px;
}
|
|
As part of a previous styling discussion in this article, we added a "City State Zip" Data Section to the "Address Info" Data Section. This was purely academic and only done to illustrate some styling considerations when you have Data Sections inside of other Data Sections.
If nothing else, the "City State Zip" section makes the Data Model look a little clunky. If we don't need it, we should just get rid of it. Let's see what happens when we do. |
|
|
|
|
|
Option 1: Change "Street Address" to a Block Element This may well be the simplest solution simply because the "Street Address" field is a single field that occupies the entire width of the document. What is a block element? It's an HTML element that occupies the entire width of whatever element its contained in. If the width of the document is analogous to the width of the Review screen, it sure seems like the "Street Address" field would be a good candidate for a block element. All we need to do is add a CSS rule for the "Street Address" field, changing its .Street_Address {
display: block;
}
Because "Street Address" is now a block element, it now takes up a whole line by itself. This is much more in line with what the document looks like. |
|
|
Option 2: Adjust Input Widths and Let Elements Wrap Lines Another option is to rely on line wrapping to get you what you want. There's only so much screen real estate for the Data Viewer to occupy. If you know roughly the size of the monitor your reviewers are using (or if you set a maximum width for a Data Section) you can control how elements wrap to subsequent lines but adjusting their widths. We can adjust the width of one or more Data Field's
|
|
|
|
|
|
|
|
|
.DataSection {
max-width: 600px;
}
Now our wrapping works as expected, regardless of the width of the Data Model panel. |
Below you will find the end-result CSS style sheet for our "Mirrored Layout" Data Model styling. You can copy and paste this text into the Style Sheet property of any Data Model.
- After reading this article, can you figure out what each of these rules is doing?
.DataField * {
display: block;
}
.DataField {
display: inline-block;
}
.Additional_Info .DataField {
display: block;
}
.Additional_Info .DataField * {
display: inline-block;
}
.Additional_Info .DataField label {
width: 132px;
}
.Address_Info {
max-width: 600px;
}
.caption {
margin-bottom: 12px;
}
.DataSection,
.DataTable,
.DataGridCollection {
background-color: rgba(0,0,0,.3);
border: 1px solid rgba(255,255,255,.25);
border-radius: 5px;
padding: 8px;
margin-top: 12px;
margin-bottom: 12px;
margin-right: 12px;
max-width: 600px;
}
.DataGridCollection .DataSection {
border: none;
background-color: rgba(0,0,0,0);
}
.DataTable {
width: auto;
}
.DataTable > *:not(.caption) {
margin-left: auto;
margin-right: auto;
}
Generic Layouts
| FYI |
The Content Model and Data Model used to demonstrate these layouts can be found in the Grooper importable ZIP file found in the About section of this article. |
The List Layout styles fields as a simple list. This type of layout will often use margins and horizontal widths to better space out a list of fields and sections of fields. Right margins are often employed to indent Data Sections to make them more visually distinct from fields at the root of the Data Model and other sections of fields.
Below is an example of a generic List Layout style sheet.
.DataField label {
width: 152px;
}
.DataSection > .DataField,
.DataSection > .DataGridCollection,
.DataSection > .DataTable,
.DataSection > .DataSection {
margin-left: 32px;
}
.DataTable > *:not(.caption) {
margin-left: 32px;
}
.DataSection,
.DataTable,
.DataGridCollection {
margin-top: 12px;
}
.DataModel > .DataSection,
.DataModel > .DataGridCollection,
.DataModel > .DataTable {
margin-left: 32px;
}
|
The Flow Layout stacks labels on top of their input boxes and lists them horizontally, wrapping fields to the next line when reaching the end of the screen (or containing HTML element). This layout can pack several fields into a relatively small space, conserving screen real estate. Label widths are typically less important to specify uses this layout. Instead Data Field horizontal margins and input widths are utilized to space out fields.
Below is a generic Flow Layout style sheet.
.DataField {
display: inline-grid;
margin-right: 16px;
}
.DataSection,
.DataTable,
.DataGridCollection {
margin-top: 12px;
}
|
The Card Layout relies heavily on Data Sections and borders to create distinct divisions between different kinds of fields on the document. Each section (or card) in the Card Layout will generally implore either a List Layout or Flow Layout within the boundaries of the card itself.
Below is a generic Card Layout style sheet.
- This style sheet also uses the
hoverandfocus-withinpseudo-elements to lighten the borders around the card upon hovering your cursor and clicking inside the Data Section (focusing within it). - No background color was added to each card/section. However, that is often included in this style approach.
- Because the fields in each card (i.e. the Data Fields in each Data Section) have a List Layout, you could call this a "List & Card Layout"
.DataField label {
width: 152px;
}
.DataSection,
.DataTable,
.DataGridCollection {
max-width: 876px;
border: 1px solid rgba(255,255,255,0.2);
border-radius: 5px;
margin-top: 16px;
padding: 16px;
padding-top: 8px;
}
.DataSection:hover,
.DataTable:hover,
.DataGridCollection:hover {
border-color: rgba(255,255,255,.4)
}
.DataSection:focus-within,
.DataTable:focus-within,
.DataGridCollection:focus-within {
border-color: rgba(255,255,255,.6)
}
|
Tips and Best Practices
Two Approaches: Global Element Styling VS Local Element Styling
|
Be aware you can style a Data Model in two ways:
|
So, why do one or the other? Let's look at the pros and cons.
|
Global Styling |
Local Styling | ||
|
Pros |
Cons |
Pros |
Cons |
|
|
|
|
Styling Flat Data Models VS Hierarchical Data Models
|
Generally speaking, there are two types of Data Models:
|
Thus far in this article, we've focused on flat Data Models to keep things simpler. Once you start working with more hierarchical models, you need to be careful about where you're editing the CSS style sheet. Each Data Model in the hierarchy has a Style Sheet property. Much like the Data Elements from each Data Model are ultimately merged to form a Document Type's Data Model the CSS rules from each style sheet is merged into a single one as well.
There may be some confusion when multiple Data Models attempt to style a specific property for an element using different values. You need to keep in mind two things:
- The most specific selector will always be applied.
- In cases where the specificity is ambiguous, the highest level Data Model's style sheet will be applied.
Draft Note: #1 below is accurate and will always be accurate. #2 will change in an upcoming release
|
Which CSS rule is applied?
|
|
|
Which CSS rule is applied?
|
Assigning Variables
Creating and Using CSS Classes
Pseudo Elements
Examples
In this section, we will post various Data Model Style Sheet examples. Use them to get ideas for what you may be able to incorporate into your own Data Models.
Comments are included in some of these style sheets to document various CSS rules. See below for an example of a comment.
/*This is a comment*/
Editor's Note: Consider all the following CSS examples a "work in progress". These styles have not been extensively tested using real-world Content Models.
Generic Examples
If you have not seen them already, be sure to check out the Generic Layouts section of this article. If you're looking for simple, generic types of layout styles you will find some there.
Simple Invoice Model Examples
These are a couple different Style Sheet examples for a PO-based invoice model.
For a lot of document cases, you can't perfectly mirror a document's layout because you are processing a lot of different versions of the same kind of document.
Invoices are a good example of this. While you're always collecting (roughly) the same data from invoices (invoice number, invoice date, balance due, etc.), each different vendor is going to have a different format.
- This Style Sheet attempts a "mixed layout" approach where the "Header Details" Data Section uses the "Flow Layout" and the "Amounts" Data Section uses a "List Layout".
- This mixed approach styles the model to look at least more like an invoice than a flat list of fields.
- This Style Sheet also styles the Data Section and Data Table captions differently (just for fun).
|
Full CSS |
Data Model Preview |
/*Generic Data Model styling*/
.DataSection {
vertical-align: top;
margin: 4px;
height: 224px;
}
.DataField label {
width: 120px;
}
.caption {
text-align: center;
border: solid rgba(255, 255, 255, .2);
border-width: 1px 0px;
margin-top: 16px;
margin-bottom: 8px;
padding: 4px 0px;
}
/*Header Details Data Section styling*/
.Header_Details {
max-width: 416px;
width: fit-content;
}
.Header_Details .DataField {
display: inline-flex;
flex-direction: column;
}
/*Amounts Data Section styling*/
.Amounts {
max-width: 252px;
text-align: right;
margin-left: auto;
margin-right: 24px;
}
.Amounts .DataField label {
margin-right: 8px;
}
|
This Style Sheet renders Data Sections as inline-block elements.
- See the difference in the two Data Model preview images where the "Amounts" Data Section is moved to come before the "Line Items" Data Table'.
- This Style Sheet also removes all Data Section and Data Table captions to give you a look at what that looks like.
|
Full CSS |
Data Element Order |
Data Model Preview |
/*Generic Data Model styling*/
.DataField label {
width: 120px;
}
.caption {
display: none;
}
.DataSection {
border: 1px solid rgba(255,255,255,.1);
border-radius: 5px;
padding: 8px;
display: inline-block;
vertical-align: top;
margin: 4px;
max-height: 216px;
}
/*Header Details Data Section Styling*/
.Header_Details {
max-width: 420px;
width: fit-content;
}
.Header_Details .DataField {
display: inline-flex;
flex-direction: column;
}
|
This Style Sheet attempts to completely invert the default color-scheme, going from a dark mode theme to a light mode one. Please note, this is the work of a CSS novice and may not be perfect, but should give you some ideas about how you can play around with color styling.
|
Full CSS |
Data Model Preview |
/*Variables*/
.DataModel {
--focus-black: rgb(0,0,0);
--unfocus-grey: rgba(0,0,0,.5);
--hover-blue: rgba(0,0,255,.5);
}
/*Generic Data Model List Layout styling*/
.DataField label {
width: 132px;
}
.DataSection > .DataField,
.DataSection > .DataGridCollection,
.DataSection > .DataTable,
.DataSection > .DataSection {
margin-left: 32px;
}
.DataTable > *:not(.caption) {
margin-left: 32px;
}
/*Color Styling. Note: "Invoice" is the name of the Content Model.*/
.Invoice {
background-color: rgb(255,255,255);
height: 100%;
}
.title-bar [title] {
color: rgb(0,0,0);
}
/*Caption Coloring*/
.caption {
color: var(--unfocus-grey)
}
/*Data Section Caption Colors*/
.DataSection:focus-within h2.caption {
color: var(--focus-black);
}
.DataSection:focus-within .DataSection h2.caption {
color: var(--unfocus-grey);
}
.DataSection .DataSection:focus-within > h2.caption {
color: var(--focus-black);
}
/*Multi Instance Data Section Caption Colors*/
.DataGridCollection:focus-within .caption {
color: var(--focus-black);
}
.DataGridCollection:focus-within .DataGridCollection .caption {
color: var(--unfocus-grey);
}
/*There might be a simpler way to do this rule. It accommodates a rare case where you have a parent multi-instance Data Section, a child single-instance Data Section and grandchild multi-instance Data Section. It styles the grandchild multi-instance Data Section's caption upon focus.*/
.DataGridCollection .DataSection .DataGridCollection:focus-within .caption {
color: var(--focus-black);
}
/*Data Table Caption Colors*/
.DataTable:focus-within div.caption {
color: var(--focus-black);
}
/*Data Field and Data Column label colors*/
.DataField label {
color: var(--unfocus-grey);
}
.DataField:focus-within label {
color: var(--focus-black);
}
th.DataColumn {
color: var(--unfocus-grey);
}
th.DataColumn.focused {
color: var(--focus-black);
}
/*Data Field and Data Column input colors. ".DataValue" is used in place of "input" to accomodate both single line and multiline fields/table cells.*/
.DataField .DataValue,
.DataColumn .DataValue {
color: var(--focus-black);
border-color: var(--unfocus-grey);
border-width: 2px;
}
.DataField:focus-within .DataValue,
.DataColumn:focus-within .DataValue, {
color: var(--focus-black);
border-color: var(--focus-black);
border-width: 2px;
}
.DataField:hover .DataValue,
.DataColumn:hover .DataValue {
border-color: var(--hover-blue);
border-width: 2px;
}
|
Another Mirrored Layout Example
|
This is another example of a "mirrored layout" styled Data Model. It aims to more closely mirror the layout of the Application For Cow Ownership document, which is a much more data dense document than our example in the Layout Styling section of this article. /*Establishes "highlight" CSS class*/
.highlight input {
color: Yellow;
font-weight: bold;
}
.highlight label {
color: DeepSkyBlue;
}
/*Establishes basic styling for Data Sections and Data Tables*/
.DataSection,
.DataTable,
.DataGridCollection {
max-width: 876px;
background-color: rgba(0,0,0,.2);
border: 1px solid rgba(255,255,255,0);
border-radius: 5px;
margin-top: 16px;
padding: 16px;
padding-top: 8px;
}
/*Colors borders around Data Sections and Data Tables when hovering your cursor over them (soft white) and entering fields (bright white).*/
.DataSection:hover,
.DataTable:hover,
.DataGridCollection:hover {
border-color: rgba(255,255,255,.3)
}
.DataSection:focus-within,
.DataTable:focus-within,
.DataGridCollection:focus-within {
border-color: rgba(255,255,255,.6)
}
/*Purely aesthetic rule to extend the background of a Data Table to the width of the widest Data Section*/
.DataTable {
width: auto;
}
/*Establishes styling ONLY for Data Fields at the first level of the Data Model's hierarchy (That is to say any Data Field NOT in a Data Section).*/
.DataModel > .DataField {
display: inline-block;
margin-right: 32px;
margin-top: 16px;
}
/*Aligns Data Field labels vertically on top of their input boxes for any Data Field in a Data Section and the "Comments" Data Field.*/
.DataSection .DataField,
.Comments {
display: inline-flex;
flex-direction: column;
}
/*Styles the Education section and its elements. Mostly, syling is done to produce two inline Data Tables inline beside the single Data Field in the section.*/
.Education {
white-space: nowrap;
}
.Education .DataTable {
display: inline-table;
padding-left: 0px;
padding-right: 0px;
background-color: rgba(255,255,255,0.05);
}
.Education .DataTable .caption {
text-align: center;
}
.Education .DataField {
text-align: center;
margin-top: 16px;
}
/*Styles Data Fields in the Signatures Data Section*/
.Signatures .DataField {
display: grid;
grid-template-columns: 250px auto;
}
.Signatures .Approval_Signature,
.Signatures .Signature_Date {
display: inline-grid;
}
|
Blur CSS Class: Protect PII & Protect Against Eye Strain
|
What it does is simple. When assigned to a Data Section or Data Table's CSS Class property, it blurs everything except the Data Section or Data Table's caption if the user is not focused inside the section or table. Effectively, all fields will be blurred out except those in the section you're actively editing.
.blur:not(:focus-within) > *:not(.caption) {
filter: blur(4px);
}
|



















































































































