We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to use glyphter svg icon in Button?

Platform: JavaScript |
Control: ejmButton |
Published Date: March 9, 2015 |
Last Revised Date: May 10, 2019
Tags: button, mobile

You can create image only button with svg icon by using imageclass property. Refer to the following steps to achieve this.

  1. First, refer to the glyphter.css file to the sample. Example, here it is referred with file name glyphter.css that is generated from the glyphter generator.

glyphter.css

/* Generated by Glyphter (http://www.glyphter.com)*/

@font-face {

    font-family: 'sample';

    src: url('../fonts/glyphter.eot');

    src: url('../fonts/sample?#iefix') format('embedded-opentype'),

         url('../fonts/sample.woff') format('woff'),

         url('../fonts/sample.ttf') format('truetype'),

         url('../fonts/sample.svg#sample') format('svg');

    font-weight: normal;

    font-style: normal;

}

[class^='icon-']:before{

 display: inline-block;

   font-family: 'glyphter';

   font-style: normal;

   font-weight: normal;

   line-height: 1;

   -webkit-font-smoothing: antialiased;

   -moz-osx-font-smoothing: grayscale

}

.icon-down:before{content:'\0041';}

.icon-up:before{content:'\0042';}

.icon-left:before{content:'\0043';}

.icon-right:before{content:'\0044';}

 

  1. Then, you need to overwrite the font family. Here, sample is set as a font-family while generating the font. Refer to the following code example.

button.html

<!DOCTYPE html>

<html>

<head>

    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no" />

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

    <meta name="apple-mobile-web-app-capable" content="yes" />

    <meta name="description" content="syncfusion" />

    <meta name="author" content="syncfusion" />

    <title>Button</title>

    <link href="themes/ej.mobile.all.min.css" rel="stylesheet" type="text/css" />

    <link href="themes/css/glyphter.css" rel="stylesheet" type="text/css" />

    <script src="scripts/jquery-1.10.2.min.js" type="text/javascript"></script>

    <script src="scripts/ej.mobile.all.min.js" type="text/javascript"></script>

    <style>

        .glyphter {

            /*Set font family style as sample*/

            font-family: glyphter !important;

        }

    </style>

</head>

<body>

</body>

</html>

 

  1. Next, set the desired image to the button. For that we have to set the imageClass property as the image class that is generated from the gliphter generator. Add the font-family class with the custom icon’s image class. Refer to the following code example.

button.html

    <table id="table">

        <tr>

            <td>

                Button Up

            </td>

            <td class="btnsht">

                <button id="button11" type="button" data-role="ejmbutton" data-ej-contenttype="image" data-ej-imageclass="glyphter icon-up"></button>

            </td>

        </tr>

        <tr>

            <td>

                Button Down

            </td>

            <td class="btnsht">

                <button id="button1" type="button" data-role="ejmbutton" data-ej-contenttype="image" data-ej-imageclass="glyphter icon-down"></button>

            </td>

        </tr>

    </table>

 

  1. Use the following styles to align the custom icon properly while using in button.

button.html

    <style>

       .e-m-btnwrapper.e-m-ios7.e-m-btn-image .e-m-btn-tag {

            padding: 5px 10px;  

        }

        .e-m-btnwrapper.e-m-flat.e-m-btn-image .e-m-btn-tag {

            padding: 8px 7px;

        }

    </style>

 

Output:

Mobile image button

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon