How to Use WordPress Dashicons (Posts, Menus and Post Types)

WordPress Dashicons arranged around a compass cursor

Dashicons are the icon font that ships with WordPress. WordPress uses them for the icons in the admin menu, and you can use them on your own site too. To show a Dashicon on the front end, load the Dashicons stylesheet, then add an element such as <span class="dashicons dashicons-admin-home"></span> wherever you want the icon.

This guide shows how to find the right icon, load Dashicons on the front end, and use them in posts, menus, widgets and custom post types, plus how to resize and color them without the usual clipping problems.

WordPress Dashicons Example
WordPress Dashicons Example

What Are Dashicons?

Dashicons became the official icon font of the WordPress admin in WordPress 3.8. The official Dashicons library lists around 340 icons in about 20 categories, from admin and post formats to social and media icons.

Because they’re a font, they scale to any size and take their color from CSS. Two limits are worth knowing before you build a design around them:

  • The set is frozen. The Dashicons project is no longer accepting icon requests, so the library won’t grow. If you need an icon that doesn’t exist, use an SVG icon or an icon block instead.
  • They aren’t loaded for visitors by default. WordPress loads Dashicons on the front end only when the admin toolbar is showing, so you see your icons while logged in but logged-out visitors usually see nothing, unless your theme or a plugin already loads them. The next section fixes that.

Find the Icon and Copy Its Code

Open the Dashicons library and browse or search for an icon.

Opening the WordPress Dashicon Library Page
Opening the WordPress Dashicon Library Page

Click an icon to see its details. Copy the CSS class, such as dashicons-format-gallery, if you need it for a menu or custom post type.

Copying a Dashicon CSS class
Copying a Dashicon CSS class

To place the icon in content, click Copy HTML instead. This gives you a ready-made element such as <span class="dashicons dashicons-format-gallery"></span>.

Push the Copy HTML Button to copy the HTML Code
Push the Copy HTML Button to copy the HTML Code

Common Dashicons Quick Reference

This table covers 24 icons that suit common front-end jobs such as navigation, contact details, shopping and social links. Use the class in HTML or a menu, and the code in CSS. I checked each one against the Dashicons stylesheet in WordPress 7.1.3.

Icon nameClassCSS code
Homedashicons-admin-home\f102
Postdashicons-admin-post\f109
Pagedashicons-admin-page\f105
Mediadashicons-admin-media\f104
Commentsdashicons-admin-comments\f101
Usersdashicons-admin-users\f110
Searchdashicons-search\f179
Menu (hamburger)dashicons-menu\f333
Lockdashicons-lock\f160
Emaildashicons-email\f465
Phonedashicons-phone\f525
Locationdashicons-location\f230
Calendardashicons-calendar-alt\f508
Clockdashicons-clock\f469
Cartdashicons-cart\f174
Stardashicons-star-filled\f155
Heartdashicons-heart\f487
Videodashicons-format-video\f126
Downloaddashicons-download\f316
External linkdashicons-external\f504
Facebookdashicons-facebook\f304
Instagramdashicons-instagram\f12d
LinkedIndashicons-linkedin\f18d
WhatsAppdashicons-whatsapp\f19a
Grid of 24 common WordPress Dashicons with their class names and CSS codes
The same 24 icons rendered on a test page, with each class and code underneath.

For all of the roughly 340 icons, with previews, use the official Dashicons library.

To show an icon without extra HTML, add it with a CSS pseudo-element. This example puts a phone icon before any link with the class phone-link:

.phone-link::before {
    font-family: dashicons;
    content: "\f525";
    vertical-align: middle;
    margin-right: 4px;
}

This still needs the Dashicons stylesheet on the front end, so add the code from the next section first.

Load Dashicons on the Front End

Add this code to your child theme’s functions.php file, or to a code snippets plugin. Don’t add it to a parent theme, because a theme update would remove it.

function howtowp_enqueue_dashicons() {
    wp_enqueue_style( 'dashicons' );
}
add_action( 'wp_enqueue_scripts', 'howtowp_enqueue_dashicons' );

If you use the built-in editor, go to Appearance > Theme File Editor (or Tools > Theme File Editor on block themes).

Theme File Editor
Theme File Editor

Select Theme Functions (functions.php) on the right.

functions PHP File
functions PHP File

Paste the code at the end of the file.

Pasting the Code For WordPress Dashicons
Pasting the Code For WordPress Dashicons

Click Update File.

Push the Update File Button
Push the Update File Button

Back up the site before editing theme files. A typing mistake in functions.php can take the whole site down. If that happens, remove the code over SFTP or your host’s file manager, and follow this guide to fixing the critical error if the site still won’t load. A code snippets plugin is safer because it can catch and disable a broken snippet.

To confirm it works, open your site in a private browser window where you aren’t logged in, and check that the icon you add in the next step appears.

Add Dashicons to Posts and Pages

In the block editor, use a Custom HTML block. If you’re new to it, my guide to adding HTML to WordPress covers the block step by step. Open the post or page you want to edit.

Post and Page Option in WordPress Dashboard
Post and Page Option in WordPress Dashboard
Push the Post Edit Button
Push the Post Edit Button

Add a Custom HTML block where you want the icon.

Push the Custom HTML Button
Push the Custom HTML Button

Click Edit code on the block, paste the HTML you copied into the HTML tab and click Update. Add aria-hidden="true" so screen readers skip the decorative icon, and keep any meaningful text next to it:

<span class="dashicons dashicons-format-gallery" aria-hidden="true"></span> Photo gallery
Custom HTML block code editor in WordPress 7.1 with a Dashicons span in the HTML tab
The Edit code dialog in WordPress 7.1. The preview doesn’t load the icon font, so the icon only appears on the front end.

Click Save (or Publish for a new post).

Save button in the WordPress 7.1 post editor
On a published post, the button at the top right reads Save.

View the post to check the icon.

Dashicons showing on the front end next to Photo gallery and Home
On the front end, the gallery icon from the Custom HTML block and the home icon on a menu link both appear.

Add Dashicons to Menu Items

On classic themes, go to Appearance > Menus. If you need a copy of a menu to experiment on first, see how to duplicate a menu in WordPress.

WordPress Menu Option under Drop Down List
WordPress Menu Option under Drop Down List

Add the page you want to the menu, then expand it under Menu Structure.

Selecting the Pages for Menu
Selecting the Pages for Menu
Menu Structure
Menu Structure

If you’re an administrator, menu labels accept HTML, so put the icon element in the Navigation Label field before the text. On multisite, where only Super Admins have the unfiltered_html capability, or for any user without it, WordPress strips the span, so use the CSS class method below instead:

<span class="dashicons dashicons-admin-home" aria-hidden="true"></span> Home

Pasting only the class name into the Navigation Label, such as dashicons-admin-home Home, doesn’t work because it shows the class name as text. Click Save Menu, then check the menu while logged out.

Block themes use the Navigation block instead of this screen. Select the link, open the settings (gear) tab in the block sidebar and type dashicons-before dashicons-admin-home in Advanced > Additional CSS class(es). The dashicons-before class tells the Dashicons stylesheet to draw the icon before the link text. I tested this on a Navigation link in Twenty Twenty-Five, and the same two classes work in the CSS Classes field on the classic Menus screen (turn it on under Screen Options).

Navigation link block with dashicons-before dashicons-admin-home in Additional CSS classes
The menu link’s Additional CSS class(es) field. The editor doesn’t load the icon font, so check the icon on the front end.

Check the result on the front end while logged out.

Add Dashicons to Widgets

Widget areas use blocks too. On a classic theme, go to Appearance > Widgets, add a Custom HTML block to the widget area, and paste the same kind of element you used in posts. Click Update to save the widgets.

Push the Widgets Button Under Appearance Section
Push the Widgets Button Under the Appearance Section

Block themes such as Twenty Twenty-Five don’t have a Widgets screen. Their sidebars and footers are template parts, so go to Appearance > Editor > Patterns, open the template part you want to change, such as Footer, add a Custom HTML block where you want the icon and click Save. The icon then appears on every page that uses that template part.

Give a Custom Post Type a Dashicon

A custom post type shows a generic pin icon in the admin menu unless you set one. (For other admin tweaks, see my guide to customizing the WordPress admin dashboard.) In code, pass the icon class as menu_icon when you register the post type:

register_post_type( 'book', array(
    'label'     => 'Books',
    'public'    => true,
    'menu_icon' => 'dashicons-book',
) );

Admin pages you add with add_menu_page() accept a Dashicons class in the same way. Both fields also accept a base64-encoded SVG data URI if you want an icon that isn’t in the set.

If you created the post type with the Custom Post Type UI plugin, go to CPT UI > Add/Edit Post Types and select your post type.

CPT UI Option on Left Side of WordPress Dashboard Button
CPT UI Option on Left Side of WordPress Dashboard Button
Push the Add or Edit Post Types
Push the Add or Edit Post Types

Under Menu Icon, click Choose dashicon.

Push the Choose Dashicons Button
Push the Choose Dashicons Button

Pick an icon.

Scrolling down to pick the Desired WordPress Dashicons
Scrolling down to pick the Desired WordPress Dashicons

Click Save Post Type (or Add Post Type if you’re creating a new one). The new icon appears in the admin menu.

Push the Add Post Type Button
Push the Add Post Type Button

You don’t need to load Dashicons in the admin. WordPress already loads them on every admin screen.

Change Dashicon Size, Color and Hover Effects

Go to Appearance > Customize > Additional CSS, or Appearance > Editor > Styles on block themes, then open the More (⋮) menu and choose Additional CSS.

Appearance and Customize Option
Appearance and Customize Option
Push the Additional CSS Button
Push the Additional CSS Button

Size: Dashicons have a fixed width and height of 20 pixels. If you only change font-size, larger icons get cut off. Change all three together:

.dashicons {
    font-size: 32px;
    width: 32px;
    height: 32px;
}
Pasting the CSS code in the Additional CSS Box
Pasting the CSS code in the Additional CSS Box

Color: icons use the text color, so set color:

.dashicons {
    color: #d54e21;
}

Hover: change the color when a visitor points at a linked icon:

a:hover .dashicons {
    color: #0073aa;
}

In the Customizer, click Publish. In the Site Editor, click Save. These rules affect every Dashicon on the front end. To style one icon only, add your own class to it, for example <span class="dashicons dashicons-star-filled rating-star">, and target .rating-star.

Press the Publish Button
Press the Publish Button

Make Dashicons Accessible

  • Add aria-hidden="true" to decorative icons so screen readers don’t announce them.
  • If an icon is the only content of a link or button, add text for screen readers, for example <span class="screen-reader-text">Search</span>.
  • Don’t rely on an icon alone to explain an action. Pair it with a visible label where you can.
  • Check that icon colors have enough contrast with the background.

Troubleshooting Dashicons

ProblemLikely cause and fix
Icons show when logged in but not for visitorsDashicons aren’t loaded on the front end. Add the code from the Load Dashicons on the Front End section.
An empty square or nothing appearsThe class name is misspelled, or the element is missing the base dashicons class. Use both classes, for example dashicons dashicons-admin-home.
Large icons are cut offOnly font-size was changed. Set width and height to the same value.
The menu shows the class name as textThe class was pasted as plain text. Use the full <span> element in the label, or put dashicons-before dashicons-admin-home in the CSS Classes field.
The icon doesn’t show in the editor or the Edit code previewThe editor preview doesn’t load the Dashicons font. Save the post and check the icon on the front end.
The site broke after editing functions.phpRemove the code over SFTP or your host’s file manager, then add it again with a code snippets plugin.

Frequently Asked Questions

Why are Dashicons not showing on the front end?

By default, WordPress doesn’t load the Dashicons stylesheet for logged-out visitors, so icons that look fine while you’re logged in disappear for everyone else. Enqueue the dashicons style on wp_enqueue_scripts with the code in the Load Dashicons on the Front End section, then test in a private window.

Can I add my own icons to Dashicons?

No. Dashicons is a fixed icon font and no longer accepts new icons. For a custom post type or admin page, you can use a base64-encoded SVG as the menu_icon instead. On the front end, use an SVG or an icon block.

Do Dashicons slow down my site?

The stylesheet and font are small, but loading them on every page is wasted work if you only use one or two icons. For a single icon, an inline SVG is lighter. Many themes and block plugins also include their own icon sets.

Are Dashicons deprecated?

No. They are still the icon font of the WordPress admin and still work on the front end. The project has simply stopped adding new icons.

Related Posts

2 Comments

  1. Hey Muhammad, thanks for writing this post, very informative! I have a question if you don’t mind, how can I change the search icon on the upper right corner of the WordPress site to the dashicons-search? This I couldn’t do in the menu section and I couldn’t figure out how to do this with CSS. Can you help? Thanks!

    1. Hey Charice,

      Absolutely! I’m glad you found the article informative. To change the search icon on your WordPress site to the “dashicons-search”, you’ll need to use some CSS. Here’s a step-by-step breakdown for you:

      Step 1: First, make sure you have the “Dashicons” font enqueued on your site. If you’re using the WordPress admin, it’s already enqueued for you.
      Step 2: Go to the “Appearance” section in your WordPress dashboard.
      Navigate to “Customize.”
      Step 3: From there, go to the “Additional CSS” section.
      Step 4: In the “Additional CSS” box, enter the following code:

      .your-search-icon-selector:before {
      content: “\f179”;
      font-family: “dashicons”;
      }

      Note: Replace “.your-search-icon-selector” with the actual CSS selector for your search icon. If you’re not sure about the selector, right-click on the icon on your site, choose “Inspect”, and identify the relevant CSS class or ID.

      Step 5: After pasting, click “Publish.”

      This will replace the current search icon with the “dashicons-search” icon. If you face any issues, let me know! Always here to help.

      Best wishes,
      Shakeel

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to our Monthly Newsletter

Get monthly updates of WordPress tips, tricks, and tutorials in your email.

Thanks. You have successfully subscribed.