{"id":603,"date":"2025-03-31T09:37:22","date_gmt":"2025-03-31T08:37:22","guid":{"rendered":"https:\/\/blog.lboro.ac.uk\/rdm\/?p=603"},"modified":"2025-03-27T09:41:00","modified_gmt":"2025-03-27T08:41:00","slug":"three-tips-on-making-shiny-apps-more-accessible","status":"publish","type":"post","link":"https:\/\/blog.lboro.ac.uk\/rdm\/2025\/03\/three-tips-on-making-shiny-apps-more-accessible\/","title":{"rendered":"Three tips on making Shiny apps more accessible\u00a0"},"content":{"rendered":"\n<p class=\"has-text-align-right\"><strong>By Lara Skelly &amp; Emma Hibbert<\/strong><\/p>\n\n\n\n<p><em>Disclaimer: This post is about R, R\/Shiny and accessibility. If you don&#8217;t know what any of that is, please stop reading now and have a cup of your chosen beverage. It&#8217;s guaranteed to be more enjoyable than reading this \ud83d\ude42<\/em><\/p>\n\n\n\n<p>Using R to create dynamic websites is a fun way of making research more accessible. With the ability to fully customise the look and feel through cascading style sheets (css), it\u2019s little wonder that the developers of this library opted for something quite bland as their out-of-the-box styles. Unfortunately, for the R-coders, it means that you have to remember to style for accessibility.<\/p>\n\n\n\n<p>Below are three tips we\u2019ve come up with to improve the accessibility of all the apps we make.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. <strong>Explicitly code for h1 headings<\/strong><\/h2>\n\n\n\n<p>The basic titlePanel is an h2 heading, so you have to alter this to an h1 heading. You can do this in your css, or directly in the code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>titlePanel( \n\n  tags$h1(\"Your App Title\", class = \"title\") \n\n) <\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>2. Change the navigation bar colours&nbsp;<\/strong><\/h2>\n\n\n\n<p>The greys of the standard Shiny app navigation bar do not meet colour contrast standards. The <a href=\"https:\/\/rstudio.github.io\/bslib\/articles\/dashboards\/index.html#theming\" target=\"_blank\" rel=\"noreferrer noopener\">bslib library<\/a> allows developers to add the <a href=\"https:\/\/bootswatch.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Bootswatch<\/a> themes, some of which have a better colour contrast. You can also change this with a custom css:&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.navbar { \n\n    background-color: #222 !important;  \n\n    color: white !important; \n\n    border-bottom: 3px solid #000;  \n\n} \n\n \n\n.navbar-nav &gt; li &gt; a { \n\n    color: #f1f1f1 !important;  \n\n} \n\n \n\n.navbar-nav &gt; li.active &gt; a, \n\n.navbar-nav &gt; li.active &gt; a:focus, \n\n.navbar-nav &gt; li.active &gt; a:hover { \n\n    background-color: #666 !important;  \n\n    color: white !important; \n\n} \n\n \n\n.navbar-nav &gt; li &gt; a:hover { \n\n    background-color: #777 !important;  \n\n    color: #fff !important;  \n\n} \n\n \n\n.navbar .navbar-header .navbar-brand { \n\n    color: #ffffff !important;  \n\n    font-weight: bold; \n\n}  color: #ffffff !important; \n\n  border-radius: 5px; \n\n} <\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>3. Include an Accessibility Statement&nbsp;<\/strong><\/h2>\n\n\n\n<p>If your app is going to be a standalone website, and not embedded somewhere, then it needs to have an accessibility statement. You could create one that you use across all your apps, linking to it in your app. That\u2019s what we\u2019ve chosen to do, putting this code at the end of the ui.R:&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  tags$div(class = \"footer\",  \n\n           fluidRow( \n\n             column(12,  \n\n                    tags$a(href = 'https:\/\/doi.org\/10.17028\/rd.lboro.28525481',  \n\n                           \"Accessibility Statement\") \n\n             ) \n\n           ) \n\n  ) <\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Tools to help you check the accessibility<\/strong>&nbsp;<\/h2>\n\n\n\n<p>The Web Content Accessibility Guidelines (WCAG) <a href=\"https:\/\/www.w3.org\/WAI\/test-evaluate\/\" target=\"_blank\" rel=\"noreferrer noopener\">evaluating web accessibility overview<\/a> has a range of guidance and tutorial videos regarding checking your site or app for accessibility. They also provide a <a href=\"https:\/\/www.w3.org\/WAI\/test-evaluate\/tools\/list\/\" target=\"_blank\" rel=\"noreferrer noopener\">web of accessibility tools list<\/a> with evaluation tools that are free to use.&nbsp;&nbsp;<\/p>\n\n\n\n<p>Government guidance provides a range of resources and blogs regarding accessibility and meeting the needs of various users. The <a href=\"https:\/\/accessibility.blog.gov.uk\/2016\/09\/02\/dos-and-donts-on-designing-for-accessibility\/\" target=\"_blank\" rel=\"noreferrer noopener\">dos and don&#8217;ts of designing for accessibility<\/a> provides useful information regarding guidance and best practice.&nbsp;&nbsp;<\/p>\n\n\n\n<p><a href=\"https:\/\/wave.webaim.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">WAVE accessibility checker<\/a>\u00a0provides a suite of evaluation tools that support making web content more accessible to individuals with varied needs. Tools include easy-to-use browser extensions to assess accessibility in any web browser.\u00a0<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Examples of Shiny apps from Loughborough University Library<\/strong>&nbsp;<\/h2>\n\n\n\n<p>If you are curious about what kind of Shiny apps we\u2019ve been working on, take a look at these:&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/research-data-lboro.shinyapps.io\/WordCloudMyRepo\/\" target=\"_blank\" rel=\"noreferrer noopener\">Word Cloud My Repo<\/a>: Create word clouds from a list of titles chosen in the Loughborough University Research Repository.&nbsp;<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/research-data-lboro.shinyapps.io\/WEDCIllustrationsGraphics\/\" target=\"_blank\" rel=\"noreferrer noopener\">WEDC Illustrations and Graphics<\/a>: A collection of illustrations and graphics produced by the Water Engineering and Development Centre (WEDC)&nbsp;<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/research-data-lboro.shinyapps.io\/FutureFlightScenarios\/\" target=\"_blank\" rel=\"noreferrer noopener\">Future Flight Scenarios<\/a>: Imagine a future where flying is different&nbsp;<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-align-right\"><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>By Lara Skelly &amp; Emma Hibbert Disclaimer: This post is about R, R\/Shiny and accessibility. If you don&#8217;t know what any of that is, please stop reading now and have a cup of your chosen beverage. It&#8217;s guaranteed to be more enjoyable than reading this \ud83d\ude42 Using R to create dynamic websites is a fun [&hellip;]<\/p>\n","protected":false},"author":720,"featured_media":608,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"lboro_blog_alternative_thumbnail_image":"608","footnotes":"","_links_to":"","_links_to_target":""},"categories":[130],"tags":[131,133,132],"class_list":["post-603","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-accessibility","tag-accessibility","tag-r-code","tag-shiny"],"_links":{"self":[{"href":"https:\/\/blog.lboro.ac.uk\/rdm\/wp-json\/wp\/v2\/posts\/603","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.lboro.ac.uk\/rdm\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.lboro.ac.uk\/rdm\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.lboro.ac.uk\/rdm\/wp-json\/wp\/v2\/users\/720"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.lboro.ac.uk\/rdm\/wp-json\/wp\/v2\/comments?post=603"}],"version-history":[{"count":5,"href":"https:\/\/blog.lboro.ac.uk\/rdm\/wp-json\/wp\/v2\/posts\/603\/revisions"}],"predecessor-version":[{"id":610,"href":"https:\/\/blog.lboro.ac.uk\/rdm\/wp-json\/wp\/v2\/posts\/603\/revisions\/610"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.lboro.ac.uk\/rdm\/wp-json\/wp\/v2\/media\/608"}],"wp:attachment":[{"href":"https:\/\/blog.lboro.ac.uk\/rdm\/wp-json\/wp\/v2\/media?parent=603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.lboro.ac.uk\/rdm\/wp-json\/wp\/v2\/categories?post=603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.lboro.ac.uk\/rdm\/wp-json\/wp\/v2\/tags?post=603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}