Styling with Law Widgets
Adding styles to the document content.
Last updated
Adding styles to the document content.
Last updated
Installing the Law Widgets web components library
Using Law Widgets to add styles to document content
Customising styles with CSS
Akoma Ntoso HTML documents don't look very good without styling. Laws.Africa's is a collection of web components that make it simple to style the HTML provided by the Laws.Africa Content API.
Using Law Widgets is easy:
Add a reference to the Law Widgets javascript.
Use the law widgets in your HTML.
We'll use the widget to apply appropriate styles to the expression HTML in expression_detail.html
.
If you refresh your expression page in your browser, you should now have a well-styled document.
We included the frbr-expression-uri attribute on the <la-akoma-ntoso>
element. If you inspect the <la-akoma-ntoso>
element in your browser's inspector, you'll see that new attributes have been added automatically:
These additional attributes are derived from the Expression FRBR URI. They allows Law Widgets (and you) to customise the applied styles depending on a country's legal tradition.
For example, in Namibia's legal tradition editorial comments are green and bold. This styling is applied based on CSS selectors that work on the FRBR attributes added above.
You can easily apply your own CSS styles to the Akoma Ntoso HTML using regular CSS selectors.
For example, we can add a red border to all sections, except for Kenya (country code KE) where we can add a green border:
You can use different attribute-based CSS selectors to change styling for different document types, countries, localities and languages.
You can also work directly with the Law Widget SCSS styles without using Law Widgets. See for more details.
The different legal tradition styles that Law Widgets supports are in the .