What are some strategies for effectively utilizing GitHub's primer and octicons?

Utilizing GitHub's primer and octicons. Upon installation with npm, I incorporated the css classes provided by GitHub through the inclusion of the build.css file in my HTML document. How can I direct the project to access all the SVG icons offered by octicons?

<!DOCTYPE html>
<html lang="en>

<head>
    <meta charset="UTF-8>
    <title>Hello Primer</title>
    <link rel="stylesheet" href="node_modules/primer-css/build/build.css>
</head>

<body>
    <form>
        <div class="input-group">
            <input class="form-control" type="text" placeholder="Username">
            <span class="input-group-button">
      <button class="btn">
        <span class="octicon octicon-clippy"></span>
            </button>
            </span>
        </div>
    </form>
</body>

</html>

Answer №1

[update] quick solution: make sure to include

node_modules/octicons/build/font/octicons.css

This method works smoothly, excluding svg icons. If the preference is for using svg icons, it might be better to incorporate the images with <img> tags. Nevertheless, opting for a font simplifies the process.

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8>
    <title>Hello Primer</title>
    <link rel="stylesheet" href="node_modules/primer-css/build/build.css">
    <link rel="stylesheet" href="node_modules/octicons/build/font/octicons.css">
</head>

<body>
    <form>
        <div class="input-group">
            <input class="form-control" type="text" placeholder="Username">
            <span class="input-group-button">
                <button class="btn">
                    <span class="octicon octicon-clippy"></span>
                </button>
            </span>
        </div>
    </form>
</body>

</html>

Update

If preferred, here's an alternative version utilizing svg:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8>
    <title>Hello Primer</title>
    <link rel="stylesheet" href="node_modules/primer-css/build/build.css">
    <link rel="stylesheet" href="node_modules/octicons/build/octicons.css">
</head>

<body>
    <form>
        <div class="input-group">
            <input class="form-control" type="text" placeholder="Username">
            <span class="input-group-button">
                <button class="btn">
                    <span class="octicon octicon-clippy"></span>
                    <img src="node_modules/octicons/lib/svg/clippy.svg"></img>
                </button>
            </span>
        </div>
    </form>
</body>

</html>

Answer №2

Is there a reason we shouldn't utilize the cdn link or simply download from there?

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Primer/3.0.1/css/primer.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/octicons/3.5.0/octicons.min.css">

Answer №3

To easily add Octicons to your project, use Bower for installation.

Include the following code in your bower.json file:

{
    "name": "my-app",
    ...
    "dependencies": {
        "octicons": "4.3.0",
    }
}

Don't forget to link to the location where your Bower libraries are stored:

<link href="/libs/octicons/build/font/octicons.css" rel="stylesheet">

Answer №4

Fast forward to the year 2023:

I encountered a similar issue where I found it frustrating that even though I was using Bootstrap icons and Devicon from CDN-distributed CSS, I still had to individually import Octicon SVGs. To tackle this problem, I decided to create my own build pipeline that consolidates the SVGs into a CSS distribution. You can check out the project repository, and if you prefer using CDN, simply include the following link:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/octicons-css/octicons.min.css">

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to reference a JavaScript or jQuery variable within a PHP variable?

Is it possible to read a javascript or jquery variable through php code? For example: <script> var num = 3; </script> <php? $a = 20; $b = num*$a; // Is this valid? ?> Any thoughts on this? ...

The issue with the <Button> component not properly linking in next.js

Having trouble with a button wrapped inside a custom Navbar component. The code snippet in question is: <NavBtn> <Link href="/contact" passHref> <Button> Contact Me </Button> </Link> & ...

Is there a way to insert a clickable hyperlink in the text of a MessageDialog?

I am currently working on MessageDialog code that looks like this: MessageDialog dlg = new MessageDialog("None of the images you selected contain location information. You can add your own after downloading http://exifpilot.com/"); await dlg.ShowAsync(); ...

Limit on the number of rows/entries selected for each query and the maximum

Is it possible to set a limit on data selection in a drop-down list through coding? For example, having 3 selections in one drop-down list, with each selection limited to 20 people choosing from the data. <tr><td><label><font face=&a ...

Conceal Element without Eliminating from the Design

Need a solution: I have specific icons to display for certain elements, but not all. However, when hiding the icon, I want the spacing of the element to stay consistent. Is there a method to conceal an image within an element while preserving its allocat ...

Is there a way to use JavaScript or jQuery to automatically convert HTML/CSS files into PDF documents?

While using OS X, I noticed that in Chrome I have the option to Save as PDF in the print window by setting the destination to "Save as PDF". Is this feature available on Windows? Is there a way to easily save to PDF with just one click? How can I access t ...

Unable to access content in the mail body of Outlook webmail via mailto

I have successfully created a mailto URL for Outlook (web version), but now I am facing challenges with implementing it on the web version OWA. Here is the URL that I am struggling with: <a href='https://company.domain.com/owa/?ae=Item&a=New& ...

Creating a responsive two-column grid in Bootstrap 4.4 is a straightforward process that

Currently using Bootstrap 4.4.1. Experimented with a 2-column layout: Image on the left and Text on the right. <section class="resume-section-first p-3 p-lg-5 d-flex align-items-center" id="about"> <div class="w-100"> < ...

Paper.js: Is there a way to prevent canvas height and width from changing when the window is resized?

My canvas with paperjs is set up to resize dynamically when the window is resized. I appreciate any help in advance. HTML <canvas id="myCanvas" height="800" width="1000"></canvas> JS var Initialize = function () { var canvas = document ...

Incorporating a PHP script into an HTML document for display

I have a PHP file that retrieves line items from a database and displays them in a table. On an HTML page, I have a form for adding items to the database that houses a restaurant menu. I want to embed the PHP script responsible for showing the line items i ...

Developing an interactive selector within the on() event handler

My goal is to utilize the on() event for managing dynamically created code. It functions properly when the selector is hardcoded in the on() event. However, I aim to enable it to select different elements depending on which box they choose. $("body").on( ...

Choosing a menu option with jQuery

Can someone help me with making a menu option selected in HTML? Here is my code: <ul class="ca-menu"> <li> <a href="#"> <span class="ca-icon"><img src="images/home.png" ...

Troubleshooting: CSS Animation Not Showing up on Screen

When I was attempting to create a JavaScript game in HTML, I encountered a problem. Despite ensuring that the syntax was correct and conducting some research online, the animation refused to display. No matter how many times I tried, it just would not work ...

What is the best way to open an already existing tab in Safari using an HTML 'a' link?

Is it possible to return to Safari after launching another app? <a href="webbrowserapp://example.com/open?url=http.....">Open WebBrowserApp</a> I've tried using: <a href="safari://">Return to Safari</a> It would be ideal if ...

Can anyone shed some light on why the CSS code is not functioning properly within my HTML file?

My CSS doesn't seem to be working in my HTML. I have linked it correctly, but it's not displaying properly - even showing empty in the CSS tab of Chrome Inspector. The links are there, so I'm not sure why it's not functioning correctly. ...

Convert text into a clickable link

Creating a form with numerous text fields, some of which require numerical input. The main goal is to have users enter a tracking number, order number, or any other type of number that, when submitted, will open a new URL in a separate window with the spec ...

Using Vue.js to update the v-bind:style when the mouse hovers over the element

I am working with a span element that displays different background images based on certain conditions. Here is the HTML: <span v-if="type" :style="styles" > </span> In the computed properties section: ...

Show or conceal input fields depending on the selection of radio buttons

Hello everyone, I am new to JavaScript and currently learning. Can someone please assist me in fixing this code? The required inputs are: radio-button-1; radio-button-2; input-fields-set-1; input-fields-set-2; input-field-submit. My objective is: Upon ...

Avoiding Event Listener Activation for Numerous Dropdown Menus

I am currently working on a project that involves fetching data from a back-end Flask server by triggering an AJAX request when interacting with multi-checkbox drop-down menus. These drop-down menus, named "Select Date" and "Select Channel", are used to se ...

What is the process for incorporating a unique pop-up window in Shopify?

Hey there! I'm looking to incorporate a pop-up window that will appear when a user clicks on a link or button on the product page. This pop-up will display washing instructions, for example. I came across this code snippet, but it doesn't seem t ...