Modify the font style of the recommended actions buttons within the webchat interface

I am attempting to modify the font of the "suggested actions" button similar to how it is demonstrated in this reference for changing the font of the bubble text: https://github.com/Microsoft/BotFramework-WebChat/blob/master/SAMPLES.md

In the provided example, they alter the fontFamily of the "textContent" element.

I have tried implementing something like this:

styleSet.suggestedAction= {
   ...styleSet.suggestedAction,
   "> button.fontFamily": "'Xy font', sans-serif"
};

However, I do not possess expertise in CSS, so any assistance would be greatly appreciated.

Answer №1

When it comes to making changes in Web Chat, you have two paths to choose from, each with its own considerations.

The first option involves updating the default value that appears when Web Chat is rendered in React. By simply passing your new value through renderWebChat, you can achieve this. This approach is highly recommended by the BotFramework-WebChat team as it minimizes the risk of future disruptions for developers. Moreover, only the properties you modify will be affected, leaving the rest of the defaults untouched.

It's important to note that selecting this option will alter the font settings globally for web chat.

const styleOptions = {
  primaryFont: "'Arial', sans-serif"
}

[...]

window.WebChat.renderWebChat( {
  directLine: [...],
  styleOptions
});

https://i.sstatic.net/4W3HZ.png

The second option entails creating a new styleSet where you can specify the desired modifications. However, since you're directly targeting a DOM element and property within web chat, any future updates that affect these elements or properties may lead to compatibility issues. Furthermore, you'll need to provide values for all properties, effectively replacing all default settings in web chat.

You can still utilize the default styleSet properties, such as primaryFont. For more extensive customizations, you'd incorporate them using styleSet.suggestedAction. The default values are available here in the BotFramework-WebChat repo for reference.

const styleSet = createStyleSet ( {
  bubbleBackground: 'blue',
  bubbleFromUserBackground: 'red',

  bubbleBorderRadius: 18,
  bubbleFromUserBorderRadius: 18,
} );

styleSet.suggestedAction = {
  ...styleSet.suggestAction,
  '& > button': {
    fontFamily: "'Arial', sans-serif"
}

window.WebChat.renderWebChat( {
  directLine: [...],
  styleSet
});

https://i.sstatic.net/TDfxj.png

I trust this information proves helpful!

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

How to Incorporate a Glyphicon into an ASP.NET Button with Bootstrap

I'm a beginner with bootstrap/asp.net and I think I might be making a mistake somewhere. My goal is to have a bootstrap glyphicon appear next to my button. I believe I am not able to use asp:Button, but instead should use LinkButton. Here is the code ...

Adjusting element placement on collapsed navbar using Bootstrap

I've been developing a navbar for a webpage and have successfully aligned the data left and right with the Brand in the center. However, when the navbar collapses, the alignment shifts to Left (over) Brand (over) Right. I want the Brand to remain at t ...

Employing useEffect within Material-UI tabs to conceal the third tab

At the page's initial load, I want to hide the first two tabs. The third tab should be visible with its content displayed right away. Currently, I can only see the content after clicking on the third tab. To troubleshoot this issue, I attempted to use ...

Troubleshooting: Issues with importing Less files in TypeScript using Webpack and css-loader

I am currently working on a test project using TypeScript and Webpack. I have an index.ts file and a base.less (or base.css) file imported in the index.ts, but I am experiencing errors with the css-loader. Interestingly, everything works fine when the LESS ...

Is there a way to conceal the article container?

My experience with javascript and Mapbox is still limited, so please bear with me. I am currently working on a map that showcases various restaurants in NYC and their impact during the recession. Additionally, I am trying to include small columns for artic ...

What is the best way to retrieve a property value from an object using the .find() method?

I've encountered a problem with the following code snippet in my function: let packName: string = respPack.find(a => {a.id == 'name_input'}).answer.replace(/ /,'_'); My goal is to locate an object by matching its id and retrie ...

Understanding the scope of jQuery variables within a function

myClass.prototype.toggle = function() { var elements = []; $.getJSON('http://localhost/jsoner.php', function(data) { $.each(data, function(index, value) { elements.push(value); alert(elements[0]); //this is functioning } ...

What could be the reason that a basic click function fails to locate the selector?

I have created a quick JavaScript module that opens an image and fades out a container to reveal the image. The HTML markup for the image looks like this: <div style="margin-bottom:1px;" class="rsNavItem rsThumb front"> <di ...

Custom Vue Basic String Renderer for JSONForms

I'm delving into Vue JSONForms and attempting to develop a basic custom text renderer from scratch. While I am aware of the vue-vanilla package available in JSONForms, I want to grasp the fundamental requirements for creating a custom renderer as I an ...

Ways to trigger various functions upon alteration of minimum and maximum values in a range slider bar

I am currently working on an app that features a range seek bar. My objective is to invoke a method passing the minimum value of the bar if it has been changed, and likewise to trigger another method passing the maximum value if it has been changed. Below ...

What is the best way to invoke a Rest API within a Vue component?

As a newcomer to VueJS, my goal is to create a basic page featuring a pie chart displaying some data. Currently, I have successfully displayed the chart using example data. However, I now wish to populate the chart with data fetched from an API call on my ...

Tips for releasing a dual npm package with both CommonJS and module support to ensure consistent imports of submodules

Trying to figure out how to package an NPM package so that it includes both CommonJS and ES modules that can be imported using the same absolute module path has been a challenge for me. I want to ensure that regardless of whether it's in a node or bro ...

Reorganizing form input array following the dynamic addition and deletion of fields

Currently, I am in the process of developing a custom WordPress widget that allows users to add and remove blocks of input fields in the widget back-end. While I have managed to make the add and remove functionality work smoothly, I am facing an issue when ...

Add transparency to elements that are not currently being hovered over using d3's mouseover feature

I'm attempting to implement a mouseover effect that increases the opacity of elements that are not being hovered on. My SVG map consists of various regions, with the current function applying an opacity of 0.8 to the selected region. My goal is to r ...

Using ES6, one can filter an array of objects based on another array of values

Seeking assistance with creating a function to filter an array of objects using another array as reference values. For example: The array containing objects: const persons = [ { personId: 1, name: 'Patrick', lastName: 'Smit ...

incorrect sequence of div elements appearing vertically

I'm having trouble organizing the header, page title, and navigation bar on my webpage. Despite my attempts to structure them correctly, they are not displaying in the desired order as shown below: https://i.stack.imgur.com/A3rQe.jpg The issue arises ...

Refrain from engaging with "disabled" table rows to prevent user interaction

I have an HTML table with certain rows marked as 'disabled'. To make this clear to the user, I decided to apply a blur filter to the tr, resulting in a table that looks like this: https://i.stack.imgur.com/GcX67.png NOTE: You can view a live ex ...

Error Message for Sequelize Validation Fails to Appear as Expected

I am trying to implement Sequelize model validation in order to validate a form field. When the book or author fields are left empty, I want this message to be displayed: Oops! An error occurred. "Title" is required. "Author" is required. The issue I&ap ...

How to eliminate properties from a nested array using D3

I've been attempting to filter out specific attributes from an array using D3. The array consists of values from a CSV file. Everything went smoothly for a small CSV file when I did it like this: d3.csv("foods.csv", function(data) { data.forEach(fun ...

Tips for displaying a message when clicking on the second level in fancytree.js

I'm looking to use fancytree.js to display an alert message only when clicking on nodes in the second level. For example: <ul> <li>1</li> <ul> <li>1.1</li> ...