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.0/css/ux4g-min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous"> </head> <body> <h1>Hello, world!</h1> <script src="https://img1.digitallocker.gov.in/ux4g/UX4G@1.0.0/js/ux4g.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></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, save some kilobytes by not including Popper.
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js
" integrity="sha384-oBqDVmMz9ATKxIep9tiCxS/Z9fNfEXiDAYTujMAeBAsjFuCZSmKbSSUnQlmh/jp3" crossorigin="anonymous"></script>
<script src="https://img1.digitallocker.gov.in/ux4g/UX4G@1.0.0/js/ux4g.min.js" integrity="sha384-cuYeSxntonz0PPNlHhBs68uyIAVpIIOZZ5JqeqvYYIcEL727kskC66kF92t6Xl2V" crossorigin="anonymous"></script>
CDN links #
As reference, here are our primary CDN links.
Description | URL |
---|---|
CSS | https://img1.digitallocker.gov.in/ux4g/UX4G@1.0.0/css/ux4g-min.css
|
JS | https://img1.digitallocker.gov.in/ux4g/UX4G@1.0.0/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'll see some funky and incomplete styling.
<!doctype html>
<html lang="en">
...
</html>
Responsive meta tag #
UX4G is 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
<head>
.
<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.