mini.css provides you with a modal dialog component to display messages to users. It is composed of three components - the modal dialog, the toggle button and the close button:
+
To create a modal dialog, simply create a checkbox input, applying the appropriate class to it (.modal), immediately followed by a <div> container. The former serves as your modal dialog's control, while the latter is the actual modal dialog container.
+
Create a label anywhere outside your modal dialog's container for the checkbox controlling your modal dialog. This will serve as the toggle button for your modal dialog.
+
Finally, inside your modal dialog's container, add another label for the checkbox controlling your modal dialog, applying the appropriate class (.modal-close). This will serve as the close button for your modal dialog.
+
`,
+ example: `
Modal
This is a modal dialog!
`,
+ samples: [`
<labelfor="modal-control">Show modal</label>
+
+<inputtype="checkbox"id="modal-control"class="modal">
+<div>
+<divclass="card">
+<labelfor="modal-control"class="modal-close"></label>
+<h3class="section">Modal</h3>
+<pclass="section">This is a modal dialog!</p>
+</div>
+</div>
`],
+ notes: [
+ `Modal dialogs should be used in combination with the card component for best results.`,
+ `Remember to apply the appropriate classes to any and all elements, as indicated in the examples. Failing to do so will result in the modal dialog not rendering or behaving properly.`,
+ `You can omit the toggle for the modal dialog and use Javascript to show/hide it, instead. You can also use any correctly linked label inside the modal dialog to change its state.`
+ ],
+ customization: [
+ `Background color for the modal dialog overlay can be changed by changing the value of --modal-overlay-color.`,
+ `Text color for the modal dialog close button can be changed by changing the value of the --modal-close-color.`,
+ `Background color for the modal dialog close button when focused or hovered over can be changed by changing the value of the --modal-close-hover-color.`,
+ `Universal margin for elements can be changed globally by changing the value of the --universal-margin variable. As a rule of thumb, consider the universal margin to be the distance you want your paragraphs to have from the sides of the screen.`,
+ `Universal padding for elements can be changed globally by changing the value of the --universal-padding variable.`,
+ `Universal border radius for elements can be changed globally by changing the value of the --universal-border-radius variable.`
+ ],
+ modifiers: [],
+ dos: [
+ {
+ description: `You can use the role="dialog" to add accessibility to your modal dialogs. Remember to properly label it and manage keyboard focus, as required.`,
+ sample: `
<inputtype="checkbox"id="modal-control"class="modal">
+<divrole="dialog"aria-labelledby="dialog-title">
+<divclass="card">
+<labelfor="modal-control"class="modal-close"></label>
+<h3class="section"id="dialog-title">Modal</h3>
+<pclass="section">This is a modal dialog!</p>
+</div>
+</div>
`
+ }
+ ],
+ donts: [
+ {
+ description: `You should not place anything between the checkbox controlling the modal dialog and the container.`,
+ sample: `
<inputtype="checkbox"id="modal-control"class="modal">
+<!-- Do not place other stuff between these -->
+<div>
+<divclass="card">
+<labelfor="modal-control"class="modal-close"></label>
+<h3class="section">Modal</h3>
+<pclass="section">This is a modal dialog!</p>
+</div>
+</div>
You can get started using mini.css in one of many ways. It is published on npm and yarn, so you can easily download it, using your preferred package manager:
@@ -639,11 +639,48 @@
Notes
Tooltips depend on the aria-label property, so they are fully accessible on screen readers.
Customization
Text color for tooltips can be changed by changing the value of the --tooltip-fore-color variable.
Background color for tooltips can be changed by changing the value of the --tooltip-back-color variable.
Universal margin for elements can be changed globally by changing the value of the --universal-margin variable. As a rule of thumb, consider the universal margin to be the distance you want your paragraphs to have from the sides of the screen.
Universal padding for elements can be changed globally by changing the value of the --universal-padding variable.
Universal border radius for elements can be changed globally by changing the value of the --universal-border-radius variable.
+
+
Modal dialogs
+
mini.css provides you with a modal dialog component to display messages to users. It is composed of three components - the modal dialog, the toggle button and the close button:
+
To create a modal dialog, simply create a checkbox input, applying the appropriate class to it (.modal), immediately followed by a <div> container. The former serves as your modal dialog's control, while the latter is the actual modal dialog container.
+
Create a label anywhere outside your modal dialog's container for the checkbox controlling your modal dialog. This will serve as the toggle button for your modal dialog.
+
Finally, inside your modal dialog's container, add another label for the checkbox controlling your modal dialog, applying the appropriate class (.modal-close). This will serve as the close button for your modal dialog.
+
+
Example
Modal
This is a modal dialog!
+
Sample code
<labelfor="modal-control">Show modal</label>
+
+<inputtype="checkbox"id="modal-control"class="modal">
+<div>
+<divclass="card">
+<labelfor="modal-control"class="modal-close"></label>
+<h3class="section">Modal</h3>
+<pclass="section">This is a modal dialog!</p>
+</div>
+</div>
+
+
Best practices
<inputtype="checkbox"id="modal-control"class="modal">
+<divrole="dialog"aria-labelledby="dialog-title">
+<divclass="card">
+<labelfor="modal-control"class="modal-close"></label>
+<h3class="section"id="dialog-title">Modal</h3>
+<pclass="section">This is a modal dialog!</p>
+</div>
+</div>
Do: You can use the role="dialog" to add accessibility to your modal dialogs. Remember to properly label it and manage keyboard focus, as required.
<inputtype="checkbox"id="modal-control"class="modal">
+<!-- Do not place other stuff between these -->
+<div>
+<divclass="card">
+<labelfor="modal-control"class="modal-close"></label>
+<h3class="section">Modal</h3>
+<pclass="section">This is a modal dialog!</p>
+</div>
+</div>
Don't: You should not place anything between the checkbox controlling the modal dialog and the container.
+
Notes
Modal dialogs should be used in combination with the card component for best results.
Remember to apply the appropriate classes to any and all elements, as indicated in the examples. Failing to do so will result in the modal dialog not rendering or behaving properly.
You can omit the toggle for the modal dialog and use Javascript to show/hide it, instead. You can also use any correctly linked label inside the modal dialog to change its state.
+
Customization
Background color for the modal dialog overlay can be changed by changing the value of --modal-overlay-color.
Text color for the modal dialog close button can be changed by changing the value of the --modal-close-color.
Background color for the modal dialog close button when focused or hovered over can be changed by changing the value of the --modal-close-hover-color.
Universal margin for elements can be changed globally by changing the value of the --universal-margin variable. As a rule of thumb, consider the universal margin to be the distance you want your paragraphs to have from the sides of the screen.
Universal padding for elements can be changed globally by changing the value of the --universal-padding variable.
Universal border radius for elements can be changed globally by changing the value of the --universal-border-radius variable.