Can we style Hero card buttons as rounded corners?
I have PromptOptions with ListStyle as HeroCard,. By detault it comes as rectangle. Can we style it look like rounded corner & change color & thickness' of borders? Bot developed in SDK 4 C#. Need this for web chat channel. Thanks!
Screenshots
Version
Describe the bug
To Reproduce
Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior
Additional context
[Bug]
Assigning to @CoHealer in lieu of @stevkan, please feel free to update if there are status changes.
@dnyati, you can use the following hack to alter the styling of a card. A few things to note:
- You need to match to a value that is passed in the card, not in the activity. This allows you to identify the specific card(s) in the html document to be styled. I'm matching on the button text value, for simplicity.
- Hero cards, with respect to the document, are rendered as adaptive cards which is why I am filtering by the
ac-adaptiveCardclass. - I recast the
adaptiveCards[HtmlCollection] object as a true array (cards) for iterating. - I add the
triggerclass for mapping the CSS to the card(s). - The border of the card is contained within the chat bubble. As seen in the image below, the bubble background extends beyond the card border. You can adjust the bubble styling via the
styleOptionsweb chat control, example here.
First, create the store and filter on incoming activities, messages, and on whichever element value you choose. Then, assign the class to the card.
const store = window.WebChat.createStore( {}, ( { dispatch } ) => next => async action => {
if ( action.type === 'DIRECT_LINE/INCOMING_ACTIVITY' ) {
if ( activity.type === 'message') {
let adaptiveCards = document.body.getElementsByClassName('ac-adaptiveCard');
let cards = Object.values(adaptiveCards);
for(let i = 0; i <= cards.length - 1; i++) {
if( cards[i].children[2] && cards[i].children[2].innerText && cards[ i ].children[ 2 ].innerText === 'Service details') {
cards[i].className += ' trigger';
}
}
}
}
}
Assign the CSS styling by matching on the assigned class, .trigger in this case.
.ac-container.ac-adaptiveCard.trigger {
border-style: solid;
border-color: red;
border-radius: 5px;
border-width: 2px;
}
Pass the store as a parameter.
window.ReactDOM.render(
<ReactWebChat
directLine={ directLine }
store={store}
/>,
document.getElementById( 'webchat' )
);

Hope of help!
I'm closing the issue as resolved. Please feel free to reopen should you encounter additional challenges related to this.
Hi ,
Thanks for the response this is very helpful & sorry for late reply as busy with other projects. I tried above example but when I make change it continuously goes in connecting mode & bot does not start. If I remove store it works well. I have attached my file for your reference.
BotFrame.txt