Powered by NeGD | MeitY Government of India® UX4G
Get started with UX4G
Quick start #
Get started by including UX4G's production-ready CSS and JavaScript via CDN without the need for any build steps.
-
Create a new
index.html
file in your project root. Include the<meta name="viewport">
tag as well for proper responsive behavior in mobile devices.<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>UX4G demo</title> </head> <body> <h1>Hello, world!</h1> </body> </html>
-
Include UX4G's CSS and JS. Place the
<link>
tag in the<head>
for our CSS, and the<script>
tag for our JavaScript bundle (including Popper for positioning dropdowns, poppers, and tooltips) before the closing</body>
.<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>UX4G demo</title> <link href="https://img1.digitallocker.gov.in/ux4g/UX4G@1.0.1/css/ux4g-min.css" rel="stylesheet"> </head> <body> <h1>Hello, world!</h1> <script src="https://img1.digitallocker.gov.in/ux4g/UX4G@1.0.1/js/ux4g.min.js"></script> </body> </html>
-
Hello, world! To view the UX4G page, open the page in preferred browser.
You can also include Popper and our JS separately. If you don't plan to use dropdowns, popovers or tooltips, you can save some kilobytes by not including Popper.
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script>
<script src="https://img1.digitallocker.gov.in/ux4g/UX4G@1.0.1/js/ux4g.min.js"></script>
CDN links #
As reference, here are our primary CDN links.
Description | URL |
---|---|
CSS | https://img1.digitallocker.gov.in/ux4g/UX4G@1.0.1/css/ux4g-min.css
|
JS | https://img1.digitallocker.gov.in/ux4g/UX4G@1.0.1/js/ux4g.min.js
|
You can also use the CDN to fetch any of our additional builds listed in the Contents page.
Next steps#
-
Read a bit more about some important global environment settings that UX4G utilizes.
-
Read about what's included in UX4G in our contents section and the list of components that require JavaScript below.
JS components #
Know which components specifically demand the Popper and JavaScript? Select the link below for the show components. Continue reading for a sample page template if it's about the overall page structure.
Show components requiring JavaScript
- Alerts for dismissing
- Buttons for toggling states and checkbox/radio functionality
- Carousel for all slide behaviors, controls, and indicators
- Collapse for toggling visibility of content
- Dropdowns for displaying and positioning (also requires Popper)
- Modals for displaying, positioning, and scroll behavior
- Navbar for extending our Collapse and Offcanvas plugins to implement responsive behaviors
- Navs with the Tab plugin for toggling content panes
- Offcanvases for displaying, positioning, and scroll behavior
- Scrollspy for scroll behavior and navigation updates
- Toasts for displaying and dismissing
- Tooltips and popovers for displaying and positioning (also requires Popper)
Important globals #
UX4G employs a handful of important global styles and settings, all of which are almost exclusively geared towards the normalization of cross browser styles. Let's dive in.
HTML5 doctype #
UX4G requires the use of the HTML5 doctype. Without it, you will see incomplete styling.
<!doctype html>
<html lang="en">
...
</html>
Responsive meta tag #
UX4G has developed mobile-first, a strategy in which we optimize code for mobile devices first and then scale up components as necessary using CSS media queries. To ensure proper rendering and touch zooming for all devices, add the responsive viewport meta tag to your code.
<meta name="viewport" content="width=device-width, initial-scale=1">
You can see an example of this in action in the quick start.
Box-sizing #
Changing the global box-sizing
value from content-box
to
border-box
for CSS sizing to be more obvious. This guarantees that
padding
won't change an element's final computed width, but it may
interfere with some third-party applications like Google Maps and Google Custom
Search Engine.
Use anything akin to the following if there is a need to override it:
With the aforementioned snippet, all nested components, including those with
generated content via::before and::after, will take on the designated
box-sizing
. selector-for-some-widget."
.selector-for-some-widget {
box-sizing: content-box;
}
With the above snippet, nested elements—including generated content
via
::before
and
::after
—will all inherit the specified
box-sizing
for
that
.selector-for-some-widget
.
Learn more about box model and sizing at CSS Tricks.
Reboot #
"Reboot to address incompatibilities between browsers and devices while giving slightly more opinionated resets to popular HTML elements for improved cross-browser rendering".
Follow @getUX4G on Twitter for the most recent news and amazing music videos.