Wijmo UI for the Web
Quick Start
Wijmo User Guide > Widgets > Ribbon > Quick Start

In this quick start, you'll learn how to add the Ribbon widget to an HTML project using HTML markup and jQuery script.

  1. To create a new HTML page in your favorite text editor, add the following code and save the document with an .html extension.

    Drop down and copy markup

    Paste in your favorite text editor.
    Copy Code
    <!DOCTYPE HTML>
    <HTML>
    <head>
    </head>
    <body>
    </body>
    </HTML>
    
  2. Add links to the dependencies to your HTML page within the <head> tags. Find the latest dependencies in the content delivery network (CDN) file at wijmo cdn.

    Drop down and copy references to paste inside the head tags

    References
    Copy Code
    <!--jQuery References-->
    <script src="http://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script src="http://code.jquery.com/ui/1.11.0/jquery-ui.min.js" type="text/javascript"></script>
    
    <!--Theme-->
    <link href="http://cdn.wijmo.com/themes/aristo/jquery-wijmo.css" rel="stylesheet" type="text/css" />
    
    <!--Wijmo Widgets CSS-->
    <link href="http://cdn.wijmo.com/jquery.wijmo-pro.all.3.20183.140.min.css" rel="stylesheet" type="text/css" />
    
    <!--Wijmo Widgets JavaScript-->
    <script src="http://cdn.wijmo.com/jquery.wijmo-open.all.3.20183.140.min.js" type="text/javascript"></script>
    <script src="http://cdn.wijmo.com/jquery.wijmo-pro.all.3.20183.140.min.js" type="text/javascript"></script>
  3. Add the following markup within the <body> tags to create the widget. The main <div> element creates the Ribbon widget, and we call its id attribute in jQuery to initialize it. The nested elements create the individual tools within the ribbon.

    Drop down and copy markup to paste inside the body tags

                
    Markup
    Copy Code
    <div id="ribbon">
        <ul>
            <li><a href="#FormatTab">Format Tab</a></li>
            <li><a href="#CustomizeTab">Customize Tab</a></li>
        </ul>
        <div id="FormatTab">
            <ul>
                <li id="actiongroup">
                    <button title="Save" class="wijmo-wijribbon-bigbutton" name="save">
                        <div class="wijmo-wijribbon-save"></div>
                        <span>Save</span>
                    </button>
                    <span class="wijmo-wijribbon-list">
                        <button title="Undo" class="wijmo-wijribbon-undo" name="undo"></button>
                        <button title="Redo" class="wijmo-wijribbon-redo" name="redo"></button>
                    </span>
                    <span class="wijmo-wijribbon-list">
                        <button title="Preview" class="wijmo-wijribbon-preview" name="preview"></button>
                        <button title="Clean up" class="wijmo-wijribbon-cleanup" name="cleanup"></button>
                    </span>
                    <span class="wijmo-wijribbon-list">
                        <button title="Cut" class="wijmo-wijribbon-cut" name="cut"></button>
                        <button title="Copy" class="wijmo-wijribbon-copy" name="copy"></button>
                        <button title="Paste" class="wijmo-wijribbon-paste" name="paste"></button>
                        <button title="Select All" class="wijmo-wijribbon-selectall" name="selectall"></button>
                    </span>
                    <div>Actions</div>
                </li>
                <li id="fontgroup">
                    <div title="Font Name" class="wijmo-wijribbon-dropdownbutton">
                        <button title="Font Name" name="fontname">Font Name</button>
                        <ul>
                            <li>
                                <input type="radio" id="fontNameArial" name="fontname"/>
                                <label for="fontNameArial" name="fn1" title="Arial">Arial</label>
                            </li>
                            <li>
                                <input type="radio" id="fontNameCourier" name="fontname"/>
                                <label for="fontNameCourier" name="fn2" title="Courier New">Courier New</label>
                            </li>
                            <li>
                                <input type="radio" id="fontNameTimes" name="fontname"/>
                                <label for="fontNameTimes" name="fn3" title="Times New Roman">Times New Roman</label>
                            </li>
                        </ul>
                    </div>
                    <div title="Font Size" class="wijmo-wijribbon-dropdownbutton">
                        <button title="Font Size" name="fontsize">Font Size</button>
                        <ul>
                            <li>
                                <input type="radio" id="fontSizeSmall" name="fontsize"/>
                                <label for="fontSizeSmall" name="small" title="Small">Small</label>
                            </li>
                            <li>
                                <input type="radio" id="fontSizeMedium" name="fontsize"/>
                                <label for="fontSizeMedium" name="medium" title="Medium">Medium</label>
                            </li>
                            <li>
                                <input type="radio" id="fontSizeLarge" name="fontsize"/>
                                <label for="fontSizeLarge" name="large" title="Large">Large</label>
                            </li>
                        </ul>
                    </div>
                    <span class="wijmo-wijribbon-list">
                        <button title="Background Color" class="wijmo-wijribbon-bgcolor" name="backcolor"></button>
                        <button title="Font Color" class="wijmo-wijribbon-color" name="fontcolor"></button>
                    </span>
                    <span class="wijmo-wijribbon-list">
                               <input type="checkbox" id="fontStyleBold"/>
                               <label for="fontStyleBold" name="bold" title="Bold" class="wijmo-wijribbon-bold"></label>
                               <input type="checkbox" id="fontStyleItalic"/>
                               <label for="fontStyleItalic" name="italic" title="Italic" class="wijmo-wijribbon-italic"></label>
                               <input type="checkbox" id="fontStyleUnderline"/>
                               <label for="fontStyleUnderline" id="underline" title="Underline" class="wijmo-wijribbon-underline"></label>
                               <input type="checkbox" id="fontStyleStrikeThrough"/>
                               <label for="fontStyleStrikeThrough" id="strike" name="strikethrough" title="Strikethrough" class="wijmo-wijribbon-strike"></label>
                               <input type="checkbox" id="fontStyleSubscript"/>
                               <label for="fontStyleSubscript" id="subscript" title="Subscript" class="wijmo-wijribbon-sub"></label>
                               <input type="checkbox" id="fontStyleSuperscript"/>
                               <label for="fontStyleSuperscript" name="superscript" title="Superscript" class="wijmo-wijribbon-sup"></label>
                    </span>
                    <span class="wijmo-wijribbon-list">
                        <button title="Template" class="wijmo-wijribbon-template" name="template"></button>
                    </span>
                    <span class="wijmo-wijribbon-list">
                        <button title="RemoveFormat" class="wijmo-wijribbon-removeformat" name="removeformat"></button>
                    </span>
                    <div>Font</div>
                </li>
            </ul>
        </div>
        <div id="CustomizeTab">
            <ul>
                <li>
                    <div title="Table" class="wijmo-wijribbon-splitbutton">
                        <button title="customize button" name="customcommand">Click Me</button>
                    </div>
                    <div>Customize</div>
                </li>
            </ul>
        </div>
    </div>  
    
  4. Within the <head> tags, below the references, add the following script to initialize the widget.

    Drop down and copy script to paste inside the head tags

                
    Script
    Copy Code
    <script id="scriptInit" type="text/javascript">
        $(document).ready(function () {
            $("#ribbon").wijribbon({
                click: function (e, cmd) {
                    alert(cmd.commandName);
                }
            })
        });
    </script>
       
  5. Also within the <head> tags, below the script, add the following CSS styles to set the size of the widget.

    Drop down and copy styles to paste inside the head tags

    Style
    Copy Code
    <style type="text/css">
        #ribbon
        {
            width: 500px;
        }
        #actiongroup
        {
            width: 200px;
        }
        #fontgroup
        {
            width: 250px;
        }
    </style>
  6. Save your HTML file and open it in a browser. The ribbon appears like the following live widget.
See Also

Concepts

KO